RE: Why these graphs differ?

*To*: mathgroup at smc.vnet.net*Subject*: [mg33947] RE: [mg33925] Why these graphs differ?*From*: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>*Date*: Wed, 24 Apr 2002 01:21:59 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

> -----Original Message----- > From: Vladimir Bondarenko [mailto:vvb at mail.strace.net] To: mathgroup at smc.vnet.net > Sent: Tuesday, April 23, 2002 1:14 PM > To: mathgroup at smc.vnet.net > Subject: [mg33947] [mg33925] Why these graphs differ? > > > These solutions, naturally, coincide. > > DSolve[{y'[z] == z, y[0] == 1}, y[z], z][[1, 1, 2]] > Evaluate[DSolve[{y'[z] == z, y[0] == 1}, y[z], z][[1, 1, 2]]] > > (2 + z^2)/2 > (2 + z^2)/2 > > > But, surprisingly, the corresponding graphs are not identical: > > Plot[ DSolve[{y'[z] == z, y[0] == 1}, y[z], z][[1, 1, > 2]], {z, 0, 1}] > Plot[Evaluate[DSolve[{y'[z] == z, y[0] == 1}, y[z], z][[1, 1, > 2]]], {z, 0, 1}] > > > Is it a feature or a problem? > > > Vladimir Bondarenko > > > Vladimir, observe: In[3]:= Attributes[Plot] Out[3]= {HoldAll,Protected} so they must differ! What is done in the second case? Evaluate makes the first argument to become evaluated, overriding the HoldAll attribute of Plot. Then the plotting machinery is started: a numerical argument very close to the starting point is assigned to z, this value is inserted into the result of DSolve i.e. into (z + z^2)/2 and calculated, then z is incremented and the process is repeated until it stops fulfilling the specifications for PlotPoints and MaxBend. Then the graphics elements for the plot are generated and finally displayed. What is done in the first case? Without Evaluate, the plotting machinery is started immediately: a numerical argument very close to the starting point is assigned to z, this value is inserted into DSolve i.e. giving DSolve[{y'[4.166666666666666`*^-8] == 4.166666666666666`*^-8, y[0] == 1}, y[4.166666666666666`*^-8], 4.166666666666666`*^-8][[1, 1, 2]]. DSolve doesn't work and an error message is issued, and the unevaluated expression is returned; its {1, 1, 2} Part is 4.166666666666666`*^-8 (the input value for z). Then z is incremented and the process is repeated until it stops fulfilling the specifications for PlotPoints and MaxBend. (After the third error message, they will be suppressed.) Then the graphics elements for the plot are generated and finally displayed. Obviously it's something different. -- Hartmut