| Mathematica for UNIX |
|
|
The following is the method to run Mathematica as a batch job:
math -batchinput -batchoutputm < infile > outfile
( Here please note < , > )
Documentation and HelpThere is a man page available for Mathematica. To read the manual page type:
man mathMathematica does not provide help within the math command. There is a command called mathbook which will allow you to access a Mathematica reference of available functions.
Inside Mathematica you can use the following three methods to get information on functions.
?function Gives a brief description of the function
function Gives a extended description of the function
?Ab* Shows all functions starting with "Ab"
?* Shows all functions
^.
x + Iy => The complex number (x+iy)
Re[z], Im[z], Conjugate[z], Abs[z], Arg[z]
% => The last generated results
%% => Next to last
%n => The result of the n-th line
x = value, x = y = value,
x = . or Clear[x]
x y means xy
x^2y means (x^2)y not x^(2y)
Ex: ln[1] := {3, 5, 1}
Accessing or Manipulating a single elemnet
Part[list,i], or list[[i]]Mathematica has the ability to handle both numeric and symbolic calculations. This allows users to enter algebraic formulas. This has the added advantage of being able to enter the values as they are read, and be able to evaluate results for different values.
EX: Replacing 'x'
exp /. x -> value
Several replacements
exp /. { x -> xval, y -> yval }
Expand, Factor, Simplify, ExpandAll
Together, Apart, Cancel, Collect
Expand[exp, Trig -> True]
Factor[exp, Trig -> True]
ComplexExpand, PowerExpand
D[f,x], D[f,x1,x2,...], D[f, {x,n}], Dt[f], Dt[f,x]
Intergrat[f,x], Intergrate[f, {x, xmin, xmax}],
Intergrate[f, {x, xmin, xmax}, {y, ymin, ymax}]
Sum[exp, {i, imin, imax}], Sum[ exp, {i, imin, imax}, {j, jmin, jmax}]
Product[exp, {i, imin, imax}] Solve[lhs == rhs, x]
Ex: f[x_] := exp (Defines the function f)
You can use "?f" to show the definition of f, &
Clear[f] clears the definition of f.
Look at the following example of transformation rules for functions.
Ex: 1+ f[x] + f[y]The three transformation rules shown below transforms the expression differently.
x -> value
f[x] -> exp (or value)
f[t_] -> expVectors and Matrices
Lists and lists of lists are used in mathematica to represent vectors and matrixes.
{a, b, c} => vector(a, b, c)
{{a,b,c}, {c,d,e}} => matrix(a b c)
(c d e)
Array, IdentityMatrix, DiagonalMatrix, Part
Dimensions, MatrixForm,
Inverse, MatrixPower, Det, Transpose
EigenValue, EigenVector
Unlike some other programs, Mathematica allows it's users to plot actual algebraic functions. One can do 2-d and 3-d plots with a cutomized view port. Also, users have the freedom to change the settings in graphs to customize them accordingly.
Plot[f, {x, xmin, xmax}]
Plot[f1,f2,...., {x, xmin, xmax}]
More examples can be found on page 136.
In general mathematica selects the suitable options for the graph, but
if one wants, the option command is there to change
the choices.
Axes, AxesLabel, AxesOrigin, DefaultFont, DisplayFunction
Frame, FrameLabel, FrameTicks, GridLines, PlotLabel
PlotRange, Ticks, DisplayFunction
(options that cannot be used with 'show') PlotStyle,
PlotPoints, MaxBend, PlotDivision, Compiled
show can be used for redrawing and changing options.
Plot3D[f, {x, xmin, xmax}, {y, ymin, ymax}]
Axes, AxesLabel, Boxed, ColorFunction, DefaultFont
DisplayFunction, FaceGrids, HiddenSurface, Lighting
Mesh, PlotRange, Shading, ViewPoint
Default View point = {1.3, -2.4, 2}
ListPlot, ListPlot3D, ListContourPlot, ListDensityPlot
<< Graphics'Graphics' load a package with additional graphics function
LogPlot, LogLogPlot, LogListPlot, LogLogListPlot
PolarPlot, ErrorListPlot, TestListPlot,
BarChart, PieChart, PlotvectorField, SphericalPlot3D
<< Graphics'Animation' load animation package
<< name Reads in a plaintext file.
expr >> name Outputs 'expr' to a file as plaintext.
expr >>> name DAappend 'expr' to file.
!!name Display content of plain text file.
Save: Save[" name", f,g,...] save definition for variable
Dump: In systems such as unix, one has the ability to save the
complete state of mathematica.
Dump[" namefile"]
math -x < filename> to start from dump file.