FW: R. H. Rand's permission: german translation of your "introduction to maxima"[Scanned]
Subject: FW: R. H. Rand's permission: german translation of your "introduction to maxima"[Scanned]
From: van.Nek at gmx.net
Date: Mon, 16 Jan 2006 17:20:42 +0100
Am 16 Jan 2006 um 12:15 hat Robert Gloeckner geschrieben:
> On the other hand it would be nice to have alternative examples for
> those sections, especially "Matrix calculations" and "Programming in
> Maxima". It would be very nice, if somebody could provide me with links
> to short examples.
Hello Robert,
here is one of my favourite examples I use for teaching basic programming constructs.
It is not really a computer algebra example, but is easy to understand and has some
basic programming elements in it.
(C1) roll_dice(n):= block ( /* simulation of n throws of a dice */
[ tmp, count:[0,0,0,0,0,0] ], /* local variables */
for i:1 thru n do ( /* loop */
tmp: random(6)+1, /* randomly throwing */
count[tmp]: count[tmp]+1 ), /* counting */ /* end of loop */
count )$ /* return value */
I copied this from my text editor into xmaxima and do now use this function.
(C2) roll_dice(1000);
(D2) [163, 176, 159, 148, 178, 176]
1000 or 10000 times is quite fast. For more times I compile my function.
(C3) compile(roll_dice)$
Compiling gazonk0.lsp.
End of Pass 1.
End of Pass 2.
OPTIMIZE levels: Safety=2, Space=2, Speed=2
Finished compiling gazonk0.lsp.
(C4) roll_dice(1000000);
(D4) [166351, 166425, 167102, 166591, 167192, 166339]
For what its worth
Volker