Control + Shift + Enter evaluates the highlighted part of a cell
; allows multiple commands per imput line and suppresses the output line. Especially useful with graphics to suppress the meaningless -Graphics- note under the picture.
Alt + . aborts an evaluation
Clear[var] will clear the value and definition of var
Remove[var] will completely remove var
% gives the result of the previous calculation. %% gives the result before that. %%% etc.
? or ?? give information about a function of variable (using * as a wildcard works)
Control + K will attempt to complete a command or function that you have started typing
<<Package` will load in the package
Some Constants:
Pi
E
Degree is Pi/180
GoldenRatio
Infinity
EulerGamma is Euler's constant
Catalan is Catalan's constant
Log[100] is actually ln(100). Use Log[10, x] to get the base 10 log of x.
User defined functions can made with:f[x_]:= expression The _ is critical as it identifies x as a dummy variable to be substituted in for.
:= is a delayed assignment where the right side is evaluated each time the left side is called.
g[x_]:=x^2
/; is conditional for defining piecewise functions:
g[x_]:=x^2 /; x>=0; g[x_]:=-x^2 /; x<0;
/. is the replacement operator. This allows you to substitute something in for something else:
2x+3y/.{y->x,x->y}
would give 3x+2y
Most commands can be written as expression//Command instead of Command[expression].
loops can be created with Do,While or For.
In order to get Math'ca to assume principle values in attempts to get ArcTan[ Tan[x] ] = x, try:
Unprotect[ArcTan,Tan,ArcCos,Cos,ArcSin,Sin];
ArcTan[Tan[x_]] := x /; realQ[x];
ArcCos[Cos[x_]] := x /; realQ[x];
ArcSin[Sin[x_]] := x /; realQ[x];
Protect[ArcTan,Tan,ArcCos,Cos,ArcSin,Sin];
Lists
Lists can be created by surrounding elements with braces, {}, or using the command List[].
Lists start with element number 1, not 0.
Operations done on lists are performed on each element in the list.
Range[m,n,d] generates a list of integers from m to n in increments of d.
Table[ Expression, {k, m, n, d}] generates a list of values of the expression evaluated as k varies from m to n by d.
Array[ f, n, r] generates a list of n values, starting with f[r].
Length[] returns the number of elements in a list.
First[] returns the first element in a list.
Last[] returns the last element in a list.
Part[list, k] returns the kth element of list. If k is negative, the kth element from the end of the list is returned. The same result is obtained by list[[k]].
There are many other list manipulation commands, such as: Rest, Take, Delete, Drop, Append, Prepend, Insert, ReplacePart, Sort, Reverse. RotateLeft, RotateRight, Join, Union, Intersection, and Complement.
Nested lists also use commands such as: Depth, Level, Flatten, FlattenAt, and Partition.
Important Vector Note: Math'ca does NOT differentiate between 1 x N vectors and N x 1 vectors! The . command will always produce a dot product between the two. To get the N x N matrix expected from a (N x 1).(1 x N), use the command Outer[Times, vector1, vector2].
Tables and Matrices are just nested lists.
Many of these commands require <<LinearAlgebra`MatrixManipulation` .
IdentityMatrix[n] produces an n x n identity matrix.
DiagonalMatrix[list] make a matrix with the elements of list down the diagonal.
matrix1.matrix2 returns the matrix (dot) product of the two matrices.
Matrix commands: Inverse, Det, Transpose, and Tr, find the inverse, determinate, transpose, or trace as expected.
Minors[A] returns a matrix of the minors, where each element is the determinant of a submatrix of A with the given elements row and column removed. Multiplied by a matrix of (-1)^(i+j) would give the cofactors of a matrix.
BlockMatrix[ {{a,b},{b,a}} ] will create a larger matrix by putting the given matrices in a block arrangement.
ListPlot[{{x1,y1}, {x2,y2}, ...}, options] will produce an x-y scatter plot.
Plot[f[x],{x,xmin,xmax}] will plot a two dimensional plot from xmin to xmax. More than one function can be plotted by substituting {f[x],g[x]} for f[x]
ParametricPlot[{x[t], y[t]}, {t, tmin, tmax}] plots parametric equations x[t] and y[t] from tmin to tmax.
Implicit plotting requires <<Graphics`ImplicitPlot`. After which, ImplicitPlot[ x y == (y-1)(x+2), {x, xmin, xmax}] will plot the implicit equation given. Here's an example of plotting up to the third order resonances of the tune plane.