Executable math

From OLPC
Revision as of 04:37, 12 November 2007 by Mokurai (talk | contribs) (Executable math in J)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

There are a number of free math programs available for Linux.

APL and J

The following examples are taken from Ken Iverson's language J, the latest version of APL, which is available at no charge for Linux, but without source code. The examples could be rendered in A+, which is available in Linux packages, but requires a special font. Iverson wrote books on Arithmetic, Algebra, and Calculus, all published by APL Press. There are other books in APL on probability, statistics, cryptanalysis, computer graphics, and computer design. Springer-Verlag published APL Programs for the Mathematics Classroom', which came out of the I-APL project to create free math software for schools. In the 1960s IBM loaned a 360 computer to a nearby school system for teaching math, starting in First Grade.

   NB. The J comment symbol is NB. 
   NB. The interpreter ignores anything from there to the end of the current line.
   1+2 NB. The interpreter indents to wait for input. Results of expressions are displayed with no indent.
3
   1-2 NB. Negative result
_1
   1%2 NB. Division
0.5
   2 * 3 + 5 NB. Right to left evaluation; no function priority
16
   2 * (3 + 5)
16
   (2 * 3) + 5 NB. Parentheses change order of evaluation
25
   1 2 3 + 2 NB. Add number to each element of vector
3 4 5
   a =. 3 9 7 NB. Assignment
   +/a NB. Sum
19
   #a NB. Number of items
3
   (+/a)%(#a) NB. Mean
6.333
   (+/ % #) a NB.(f g h) a is evaluated as (f a) g (h a)
6.333
   a * a
9 81 49
   +/ a * a
139
   a +/.* a NB. Vector inner product
139
   3 >. 2
3
   3 <. 2
2
   >. / a
9
   <. / a
3
   (>. / a) - <. / a
6
   range =. (>./) - (<./) NB. Function assignment
   range a
6

Maxima

A Free Software version of Macsyma.