Mathematica Reference Page
Common Mistakes
Most Mathematica syntax problems are of a very few types:
 Parenthesis (), Braces {}, and Brackets [].
 Parenthesis are for breaking up multiplication and addition
e.g. (x+2)^2 is the same as x^2 + 4 x + 4.
 Braces {} are for grouping things together
e.g. {1, 2} is the point or vector with coordinates x=1, and y2.
 Brackets [] are for functions
e.g. Sin[x].
 Capitalization. All Mathematica commands start with a
Capital letter.
 Sin[x] not sin[x].
 Plot[Cos[x],{x,0,4}] not plot[Cos[x],{x,0,4}]
 Pi or the pretty version on the Pallete not pi
 E or the pretty version on the Pallete not e
 etc.
 Missing commas.
 Plot[Cos[x],{x,0,4}] not Plot[Cos[x]{x,0,4}]
 Bad function definitions.
f[x_] = Cos[x^2]
defines a function. Common mistakes are:
 f[x] = Cos[x^2]
missing underscore.
 f(x_) = Cos[x^2]
It needs brackets [] not parens ().
examples of the error messages priduced by these errors are below.
Avoiding Common Mistakes
Avoiding these mistakes is simple:
 Parenthesis (), Braces {}, and Brackets []. Remeber the
rules:
 Parenthesis () are for breaking up multiplication and addition
 Braces {} are for grouping things together
 Brackets [] are for functions
 Capitalization. Remember ll Mathematica commands start with a
Capital letter.
 Paste from the Palette.
 Always Capitalize
 Missing commas.
 Paste from the palette and fill in the template.
 Copy carefully from the Help.
 Bad function definitions.
 Remember the underscore.
 Remember to use brackets [].
Error Messages
These syntax errors produce (once you know how to read them)
fairly clear (well compared to Matlab, Maple, Fortran, C++, Java,
etc.) error messages. the trick is to only look at the first
message.
 Parenthesis (), Braces {}, and Brackets [].
 Plot[Sin(x),{x,0,4}]
produces the error message
sin x is not a real number at x=1.66666 x 10^7
In other words it thinks sin and x are two seperate things.
 Plot(Sin[x],{x,0,4})
produces the message
"(" can not be followed by "Sin[x], {x,0,4})".
 Expand[ (x+2)^2] gives x^2 + 4 x + 4
 What do you think
Plot[ {Sin[x], Cos[x]},{x, 0, Pi}]
will give? Remember the braces group things together.
 Capitalization. All Mathematica commands start with a
Capital letter.
 Plot[sin[x],{x,0,4}]
produces the error message
sin(x) is not a real number at x=1.66666 x 10^7
In other words it does not understand sin[x].
 plot[Cos[x],{x,0,4}]
Just parrots back the command. This is what Mathematica does
when it does not know what to do. You also get a warning the
first time you do this that "plot" is similar to "Plot".
 Plot[ Cos[x],{x,0,pi}]
gives the message that
Limiting value pi in {x,0,pi} is not a real number.
 Plot[e^x, {x, 0, Pi}]
gives the messgae that e^x is not a real number at x=1.309 x 10^(7).
 Missing commas.
 Plot[Cos[x]{x,0,4}]
produces the message
Plot called with one argument; 2 or more arguments are expected.
 Bad function definitions.

After defining f[x_] = Cos[x^2]
f'[x] gives the derivative 2 x Sin[x^2].
 After running f[x] = Cos[x^2]
f'[x] simply parrots.
 f(x_) = Cos[x^2]
produces the strange message
Tag Times in ..... is protected.
