A Short Introduction to Mathematica Punctuation

Kenneth M. Levasseur
Department of Mathematical Sciences
University of Massachusetts Lowell
Kenneth_Levasseur@uml.edu

Listed below are single punctuation marks that have a special function in Mathematica.  Combined with other marks, there are many other "short" forms that are allowed.  For example,  x/.y is the short form for ReplaceAll[x,y].  It's best to pick up these short forms gradually instead of trying to digest all at once.   This is not a complete list.

,    (Comma)  is used to separate arguments of a function. 
Examples:       List[1,2,3] which is usually displayed as{1,2,3}
         Plus[a,b,c^2] which is usually displayed as  a+b+c^2
                                     or a+b+c2

.   (Period)  Used as a decimal point and also used in the short for of Dot
	For example, Dot[{a,b},{c,d}] = {a,b}.{c,d} = a c + b d.

[ ]   (Brackets) Used to enclose arguments to a function.  For example the cosine of x is Cos[x]

[[ ]]  (Double brackets)  Used to reference entries in a list and more generally arguments 
	in an expression.  For example if a={1,4,9,16} and b = w[s,t,u,v] then
	a[[2]] is 4, while b[[2]] is t.     The "zeroth" entry of an expression is its Head.  So a[[0]] is List.  

More than one level can be specified.  For example, if g={4,{7,-5}} ,  then g[[2,1]]  is the first part of the second entry, or 7.    You will get an "error message"  if you try to reference g[[1,2]]  since the first part of g  is 4, which can't be divided into parts.

{ }  (Braces)  used in the short form of List to enclose arguments to List

( )  (Parentheses) Used to group expressions.  Particularly arithmetic expressions.

:   (colon) Used for default values for optional arguments.
	For example f[x_,y_:0]:=Sin[(x^2)+y]  not only defines f for two arguments,
	but f[x]  is Sin[(x^2)].  So if the y argument is missing the default, in this case
	zero is assumed.

*  (asterisk)  Used for multiplication 
	a*b is the product of a and b; but a b  with at least one space between the two factors is the same product. So you really won't need the asterisk much.

/   (slash)  Used for division 
	a/b is the fraction (a/b) 
	
	The slash is also used in several combinations.  For example double-slash,  //,  is used for function evaluation - I use it frequently,   For example,  a//f  is an alternate form of f[a]

;    (semicolon)   is used to separate expressions in a compound expression. 

In an input cell, if an Expression is completed at a line break, the expression is considered complete and so two expressions are contained in the cell below and there are two outputs

c=2^10
Solve[x^2+x-c==0,x]

Consider the next cell.  Since the  Solve  expression is started in the first line, the rest of the line is included in that expression and there is only one Input (a product) and Output (a product of the two outputs in the previous example).

c=2^10 Solve[
x^2+x-c==0,x]

After an expression is completed, if a semicolon follows before a linebreak, the completed expression and next expression are part of a CompoundExpression, with the Output being the value of the last expression.  Whether the successive expressions are on one line or not doesn't matter.

c=2^10;
Solve[x^2+x-c==0,x]

c=2^10; Solve[x^2+x-c==0,x]

To see how Mathematica really views an input, you can "wrap" an expression with FullForm[Hold[expression]]

FullForm[Hold[a;b;]]

And the result without Hold:

FullForm[a;b;]

A few of the other characters that are used frequently are @, #, %, &, and _.   They are used alone or in combination.