Evaluate In Place

Hi Groupers:
I find the new feature (at least I think it's new with V3.0) of
Evaluating In Place to be extremely useful for debugging purposes.
Since I haven't seen it discussed in this forum I thought a note might
be appropriate.
The command is executed by selecting part of the input line and
executing the pull down command Kernel>Evaluation>Evaluate In Place.
A simple example is:
In[15]:=
x=3;
Now consider the following cell:
x^2+2x
Select x^2 and evaluate in place. Now repeat with 2x. You will get in
turn:
9+2x
9+6
A more interesting example is the following expression:
In[19]:=
x=.;
expr=(1-x)/(3(x^2+2x y))
Out[19]=
(1 - x)/(3*(x^2 + 2*y*x))
My students have some trouble understanding the internal form of
expressions like this. If we look at:
In[20]:=
FullForm[expr]
Out[20]//FullForm=
Times[Rational[1,3],Plus[1,Times[-1,x]],
Power[Plus[Power[x,2],Times[2,x,y]],-1]]
By selecting and evaluating in place
Times[-1,x]
we get:
Times[Rational[1,3], Plus[1,-x],Power[Plus[Power[x,2],Times[2,x,y]],-1]]
We can now select and evaluate in place parts of the expression to get
in turn:
Times[Rational[1,3],1-x,Power[Plus[Power[x,2],Times[2,x,y]],-1]]
Times[Rational[1,3],1-x,Power[Plus[x^2,2 x y],-1]]
Times[Rational[1,3],1-x,Power[x^2 + 2*x*y,-1]]
Times[Rational[1,3],1-x,1/(x^2 + 2*x*y)]
And finally:
In[30]:=
Times[1/3,1-x,1/(x^2 + 2*x*y)]
Out[30]=
(1 - x)/(3*(x^2 + 2*x*y))
What a great debugging tool! When faced with a deeply nested
Mathematica expression, it is now no longer necessary to physically
break it apart and execute each part in a separate cell. You can now
execute each portion in place and understand its effect.
Cheers,
--
Des Penny
Physical Science Dept.
Southern Utah University
Cedar City, UT 84720
Office: (435) 586-7708
FAX: (435) 865-8051
email: penny@suu.edu
Home: (435) 586-2286
email: dpenny@iname.com