MATHEMATICA TUTORIAL

Expressions as Trees

Here is an expression in full form.
In[1]:=
Click for copyable input
Out[1]//FullForm=
TreeForm prints out expressions to show their "tree" structure.
In[2]:=
Click for copyable input
Out[2]//TreeForm=

You can think of any Mathematica expression as a tree. In the expression above, the top node in the tree consists of a Plus. From this node come two "branches", and . From the node, there are then two branches, and , which can be viewed as "leaves" of the tree.

This matrix is a simple tree with just two levels.
In[3]:=
Click for copyable input
Out[3]//TreeForm=
Here is a more complicated expression.
In[4]:=
Click for copyable input
Out[4]=
The tree for this expression has several levels.
In[5]:=
Click for copyable input
Out[5]//TreeForm=

The indices that label each part of an expression have a simple interpretation in terms of trees. Descending from the top node of the tree, each index specifies which branch to take in order to reach the part you want.

New to Mathematica? Find your learning path »
Have a question? Ask support »