Solution
In[12]:=
In[13]:=
Note that delayed substitution produces no output.
In[14]:=
Out[14]=
In[15]:=
In[16]:=
Out[16]=
In[17]:=
Out[18]=
In[19]:=
Extra excercises
1. Think what would a:=a+1 give.
2. Try it. Try to get the value of a.
3. Interprete the result
4. What does a=a+1 give?
Clear a.
In[20]:=
Out[21]=
In[22]:=
Out[22]=
This kind of substitution leads to an infinite sequence
a=a+1=(a+1)+1=((a+1)+1)+1=...
Mathematica does the substitution 256 times, which is set as the maximum recursion depth and then prints out an error message. Using delayed and direct substitutions lead to essentially the same result. With delayed substitution, the error is generated when you try to evaluate the expression.
Remember to clear a after this!
In[23]:=
| Created by Mathematica (April 10, 2007) |