Short Mathematica Example for Numerical Methods
Lecturer: Dr. Rennan Barkana

When you use NDSolve[] in Mathematica, the resulting solution is not stored as a function. Rather, it is a kind of rule for finding the solution function. To use this rule, you have to use the Evaluate[] function, and specify the rule. So below, we call the solution rule t, and then we evaluate the function y[x] under this rule. The Mathematica notation for specifying a rule is /. Note a difference between Plot[] and ParametricPlot[]. When we Plot[] two functions, each function is plotted separately, so we write separate Evaluate[] calls. But ParametricPlot[] uses the same function twice, once for the x-value and once for the y-value of the plotted point, so there is just one Evaluate[] call around the pair of points.




t=NDSolve[{D[y[x],x]==1,y[0]==0},y,{x,0,1}]

ParametricPlot[Evaluate[{y[x] x, y[x] x^2}]/. t, {x, 0, 1}]

Plot[{Evaluate[y[x] x]/. t, Evaluate[y[x] x^2]/. t}, {x, 0, 1}]