Mathematica Notes
Maxima
Examples
Issues
An open source alternative to Mathematica - to a large extent. Both are written in Lisp.
Not case sensitive.
$ suppresses printing.
Each entry generates a variable that can be refered to.
e.g. (C4) entry as EV(c4,x=2.6);
kill(name); to remove definition.
quit();
factor(289);
expand((x+3)^3);
u:(x^3+1)^2; - assignment
diff(u,x); - differentiate
%e^(%i*%pi);
3>5;%,pred; - evaluates boolean expression.
f1(x):=x^2+sin(x); f1(.2); -defining a function.
f04(a,b) := 6*a*b-a+b;
makelist( makelist( f04(a,b),a,1,10 ),b,1,10 );
# is not equal to operator.
evenp(35); FALSE - even number?
oddp
mod(34,3); 1
random(n); [0,n-1]
subst(a,b,c); a for b into c. subst(5,x,x^2)
integrate(1/x^2,x,1,inf);
ev(d11,numer); - numerical evaluation.
(x:1,y:0,for i from 1 thru 10 do (y:y+i),y);
prod(t+i,i,1,5); - product
?round(2.3);
?truncate(ev(5/2,numer));
ev( ?truncate( log(15)/log(2) ), numer );
append( [2,3], [3,5] ); -> [2,3,3,5]
is ( 3 = 5 ) -> false, (3==5)
is ( 3 # 5 ) -> true, (3!=5)
|
e1: x^2+3*x*y+y^2; e2: 3*x+y=1; solve([e1,e2]); |
for i:1 while i<=10 do s:s+i;
fac[1](x) := 1;
fac[n](x) := n*fac[n-1](x);
f1(n) := if (evenp(n)) n/2 else 3*n+1;
In procedure "," is the statement delimiter, "$" is scope terminator.
f02(x) := block( [y],
y:1,
while x > 1 do
(
y: x*y,
x: x-1
),
y)$
f07(n) := block( [s,i], s:0, i:1, while i<n do (s:s+i, print("s=",s," i=",i),i:i+1), return(s))$
f03() := block( [i], i:1, while i<5 do ( print("i=",i), i:i-1 ) )$
/* This is a comment in Maxima */
a1[4]:2*y; a1:2
arrayinfo(a1); [HASHED,
length( [1,3,6]) -> 3
sort( [3,11,7,2] )
reverse( [3,2,1] )->[1,2,3]
batch("~/file01.txt");
- load file e.g. edited in vi
save( save01, all ); load(save01) - session
Random access arrays (effectively)
t3: [3,4,5];
t3[1] - accessing 3
makelist( binomial(6,i),i,0,6);
[1,6,15,20,15,6,1]
apply( "+", [3,4,5]); evaluates 3+4+5
apply( max, [3,4,5]); -> 5
map(f, [a,b,c] ); evaluates [ f(a), f(b), f(c) ]
for x in [a,b,c] do expr
shell (maxima) and gui (wxmaxima) installs
Linux install: # apt-get install wxMaxima