Mathematica
Tips on Syntax

These are rules by which mathematical notation is entered through the keyboard for Mathematica.

You can also enter input using the mouse with special symbol palettes, but
the ``InputForm'' syntax, below, remains valid for typed (keyboard) input.


1. Commands (function names) are capitalized
e.g.,   Sqrt,   ArcTan,   Pi,   Solve,   ListPlot3D

2. Parameters are put in square brackets, e.g.,
Cos[x],         Plot[ Sin[x^2], {x,0,5} ]

3. Lists (esp. vectors, matrices) appear in curly brackets, e.g.,
{a, b, 17},        { {1,0}, {0,1} }

4. Parentheses are for algebraic grouping; e.g.,
(x+y)^3,        (4Pi-x)/(x y + 1)

5. Double square brackets indicate an index.
For example, if       matrix = {{a, b}, {c, d}}
then

6. ``='' indicates value assignment, ``=='' indicates equality, and ``!='' indicates inequality:

equation1 = x + 3y == 8

solution = Solve[ { x+3y==8, 2x-y==7 }, {x,y} ]

If[ v != w, Print["the two values are not equal"]]

7. Multiple commands can be separated by a semicolon, e.g.,
a=3 ; b=4 ; c=a+b

and text output is suppressed if a command is followed by a semicolon, e.g.

x = N[Pi,9999];
(x is defined, but the value is not displayed)

8. Functions which take only one parameter can appear as postfix commands using `//', e.g.,
Sqrt[2] // N      or      {{a,b}, {c,d}} // MatrixForm

9. Multiplication is indicated by `*' or by juxtaposition, but be sure to separate variable names by a space, e.g.,
n * Pi     or     n Pi     but not     nPi     (however, 4Pi is OK)

10. Matrix multiplication is indicated by `.', e.g.,
Mathematica command notes
matrA . matrB
# of columns in A must
equal # of rows in B
matr . vec
# of columns in A must
equal # of elements in v
vec . matr
v is automatically transposed: vtA
vecA . vecB dot product, vectors of equal size


Next: ``Super Calculator''
Table of Contents