Mathematica >
Mathematica TutorialTutorials »

Symbolic Computation

One of the important features of Mathematica is that it can do symbolic, as well as numerical calculations. This means that it can handle algebraic formulas as well as numbers.
Here is a typical numerical computation.
In[1]:=
Click for copyable input
Out[1]=
This is a symbolic computation.
In[2]:=
Click for copyable input
Out[2]=
Numerical computation3+62-164
Symbolic computation3x-x+22+2x

Numerical and symbolic computations.

You can type any algebraic expression into Mathematica.
In[3]:=
Click for copyable input
Out[3]=
Mathematica automatically carries out basic algebraic simplifications. Here it combines x2 and -4x2 to get -3x2.
In[4]:=
Click for copyable input
Out[4]=
You can type in any algebraic expression, using the operators listed in "Arithmetic". You can use spaces to denote multiplication. Be careful not to forget the space in xy. If you type in xy with no space, Mathematica will interpret this as a single symbol, with the name xy, not as a product of the two symbols x and y.
Mathematica rearranges and combines terms using the standard rules of algebra.
In[5]:=
Click for copyable input
Out[5]=
Here is another algebraic expression.
In[6]:=
Click for copyable input
Out[6]=
The function Expand multiplies out products and powers.
In[7]:=
Click for copyable input
Out[7]=
Factor does essentially the inverse of Expand.
In[8]:=
Click for copyable input
Out[8]=
When you type in more complicated expressions, it is important that you put parentheses in the right places. Thus, for example, you have to give the expression x4y in the form x^(4y). If you leave out the parentheses, you get x4y instead. It never hurts to put in too many parentheses, but to find out exactly when you need to use parentheses, look at "Input Syntax".
Here is a more complicated formula, requiring several parentheses.
In[9]:=
Click for copyable input
Out[9]=
When you type in an expression, Mathematica automatically applies its large repertoire of rules for transforming expressions. These rules include the standard rules of algebra, such as x-x=0, together with much more sophisticated rules involving higher mathematical functions.
Mathematica uses standard rules of algebra to replace by (1+x)2.
In[10]:=
Click for copyable input
Out[10]=
Mathematica knows no rules for this expression, so it leaves the expression in the original form you gave.
In[11]:=
Click for copyable input
Out[11]=
The notion of transformation rules is a very general one. In fact, you can think of the whole of Mathematica as simply a system for applying a collection of transformation rules to many different kinds of expressions.
The general principle that Mathematica follows is simple to state. It takes any expression you input, and gets results by applying a succession of transformation rules, stopping when it knows no more transformation rules that can be applied.
• Take any expression, and apply transformation rules until the result no longer changes.

The fundamental principle of Mathematica.