Maxima
Mathematica
Mathematica Diary -
md001
md002
d003.txt
Lisp
HP 49G
TI-nspire CAS
Octave
Programming
"Mathematica A Practical Approach" by Nancy Blachman and Colin Williams is good.
Mathematica and its memory sux. I use an older version, but
often after updating a variable there is no change.
f4[x_] := ... <shift and return to update>
still no change, then for my sanity I rename the variable
to a new one say f5. This is an intermediate problem for
Mathematica, often it has no trouble updating the f4 variable,
so it is a really annoying bug because often it works and
then starts failing.
Clear[ variablename ]
g1[x_] := D[w^2+3*w,w]/.w->x; differentiate then substitute
GCD[a,b] a>b
Mod[m,n]
Quotient[18,5] -> 3
Prime[n] gives nth prime e.g Table[Prime[n],{n,1,5}]
-> {2,3,5,7,11}
PrimeQ[n] True or false if n is prime
IntegerQ[n] True of false if integer
FactorInteger[4] -> {{2,2}}
Divisors[4] -> {2,4}
EulerPhi[n] Φ(n)
Random[ Integer,{10,10001}] 10≤integer≤10001
Random[ Real,{-3,3} ]
Floor[n]
Ceiling[n]
Round[n]
Chop[n]
Log[2,2^5] -> 5
Select[ Range[101, 113], # > 106 & ] Generate a consecutive range of integers and sample with temporary function
{{1,2},{3,4}}.{{5},{6}} Matrix multiplication
| MatrixForm[ {{1,2},{3,4}} } ] | 1 2 |
| 3 4 |
Integrate[1/(1+x),x]
Solve[x*x/4+y*y/9 == 1 /. x->1.5, y]
Warning: variables returned by Solve are in no particular order,
use the /. operator. e.g. let ei have variables a[0], a[1], a[2], a[3],
sol = Solve[ {e1,e2,e3,e4},{a[0],a[1],a[2],a[3]} ]
To put the variables into an equation say f=a[1]+a[3]*t-a[0]*t^2... f /. sol
N[ Sum[ 1/(2*i+1),{i,1,Infinity}] ] -> Infinity
Product[ 2*k+1,{k,0,3}]
While[ test, body]
If[ condition, t, f]
ListPlot[ {}, PlotJoined->True, AspectRatio->1, PlotStyle->PointSize[0.02] ]
Show[%167,%168], Show[p1,p2,AxesLabel->{"x","error"}]
Plot[ {x^2,x^3},{x,0.0,1.0}]
Plot[ , PlotStyle->{ RGBColor[1.0,0.0,0.0], Dashing[.03], Thickness[.002], PlotLabel->"Title" }]
Plot[ tan[x], {x,-Pi/2,Pi}, PlotRange->{-2,2}]
ParametricPlot[{2*Cos[t],3*Sin[t]},{t,0,2*Pi}]
Plot3D[ x*y, {x,-1.0,1.0},{y,-1.0,1.0} ]
Total[{1,2,3}] ->6 sum of list Apply[Plus,{1,2,3}]
Apply[Times,{8,12,3}] -> 288 Binary Operators
t1={{1},{2},{3},{11,13}] to extract elements from list
t1[[1]] -> {1}
t1[[1]][[1]] -> 1 left to right operator [[]] precedence
t1[[4,1]] = 7 - assignment
For[ start, test, inc, body ]
ToString[ ]
StringJoin[{"s1","s2"}]
Unprotect[Cos];
Unprotect["^"];
Cos[j*Pi]:=(-1)^j;
(-1)^(2*j):=1;
Protect["^",Cos];
Flatten[ {1,2,3,{333,2}} ] -> {1,2,3,333,2}, can control depth too
Fold[ f, x0, {7,11,13} ] -> f[f[f[x0,7],11],13], nested / recursive binary function. FoldList produces sequence of folds
AppendTo[s,elem]
Append[{a,b},c} -> {a,b,c}
Prepend[{a,b},x] -> {x,a,b}
PrependTo[ ]
Insert[{a,b,c},x,2] -> {a,x,b,c}
Insert[{a,b,c},x,{{-1},{1}} -> {x,a,b,c,x}
Take[{a,b,c,d,e},-2 -> {d,e}
Position[{1+x^2,5,x^4},x^_] -> {{1,2},{3}}
Drop[{a,b,c,d,e},2] -> {c,d,e}
Reverse[{a,b,c}] -> {c,b,a}
Rest[{a,b,c}->{b,c} //removes first element
Part as operator {a,b,c}[[2]] -> b
Part[{a,b,c},1] -> a
Part[ {a,b,c}, {1,3}] -> {a,c}
ReplacePart[exp,new,n] ReplacePart[{a,b,c,d},x,3] -> {a,b,x,d}
Last[ {a,b,c} ] -> c
Delete[ {a,b,c}, 2] -> {a,c}
doesn't change initial argument, returns value
Map[ f,{a,b,c} ] -> {f[a],f[b],f[c]}
Map[ #^2 &, {7,11}]; -> {49,121}, temporary functions
MapAt[ f, {a,b,c,d}, {{1},{4}} ] -> {f[a], b, c, f[d]}
MapAt[ f, {a,b,c,d}, 2 ] -> {a, f[b], c, d}
Length[ {a,b,c} ] -> 3
Array[f,3] -> {f[1],f[2],f[3]}
Table[ f[i], {i,3} ] -> {f[1],f[2],f[3]}
Table[ {x,f[x]}, {x,-5,5,0.5} ]; -> { {-5,f[-5]}, {-4.5,f[-4.5]}, .. {5,f[5]} }
Nest[ f,x,3 ] -> f[f[f[x]]]
DeleteDuplicates[list] - unique list
Union, Intersection, Complement(subtraction), Subsets
Return[ expr ] - used to make a modual a function
Evaluate[ expr ]
f[a_] := Module[ { }, expr ]
f[arguments] := Module[ {local variables}, .. Return[ ] ];
Fit[{{-2,1},{0,0},{2,1},{3,7}},{1,x,x^2},x] least squares poly approx
Directory[] display the current directory
SetDirectory[""] FileNames[]
L1 = ReadList["data04.txt", Table[Number,{3}]] Creat a table by
reading in 3 numbers at a time into a list structure.
Limit[Tan[x],x->Pi/2] -> Infinity
Collect[ 3*x+5*x^2+z*z*x+y+2*x,x] Collect terms in powers of x
Series[Log[1+x],{x,0,5}]
s1[s_,n_] := Table[SeriesCoefficient[s,i],{i,0,n}]
Apart[1/(1-x)/(2+x)] -> -1 1
---------- + ---------
3 (-1 + x) 3 (2 + x)
Needs["Graphics`Shapes`"] refers to C:\WNMATH22\PACKAGES\GRAPHICS\SHAPES.M
f1[a_,b_,x_] := a*x+b/x; f1[a_,b_][x_] := f1[a,b,x]; f2[a_,b_,n_] := Nest[f1[a,b],1.0,n] f2[0.5,4.5,5]
(* Plot symbolic expression in t on [c+m*[0..1]] at n+1 points *)
symPlot[c_,m_,n_,f_] := Module[ {tbl},
tbl := Table[ {N[i/n*m+c], f /. t-> N[i/n*m+c]} ,{i,0,n} ];
ListPlot[ tbl, PlotJoined->True, AspectRatio->1]
]
(* Plotting a complex function *)
ParametricPlot[ {Re[f1[t]],Im[f1[t]]},{t,0,Pi}]
( + 1 3 5 )
9
expt root mod + - * /
numberp zerop plusp minusp evenp oddp > <
quit
( defun g2 (a b c )
( + a b c ) );
f04[N_,K_] := Module [ For [i=1,i<4;i=i+1;Print[i]]; ]complained about the syntax but gave little indication. Further the new versions automatically format which for people who know what they are doing is bad. For example in languages I match up begin and end statements in the same column - programming discipline. In Mathematica this is an error!
MemberQ[ [24,6,12], 12]; -> True, in set