f(x)=x: why Plot continues to add new levels of recursion?
- To: mathgroup at smc.vnet.net
- Subject: [mg121261] f(x)=x: why Plot continues to add new levels of recursion?
- From: Alexey Popkov <lehin.p at gmail.com>
- Date: Tue, 6 Sep 2011 03:58:51 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
Hello,
Please consider the following example (plotting function f(x)=x):
NumberOfEvals[r_] :=
Length[Reap[
Plot[x, {x, -Pi, Pi}, MaxRecursion -> r,
EvaluationMonitor :> Sow[x]]][[2, 1]]]
data = Table[{r, NumberOfEvals[r]}, {r, 0, 15}];
f = Fit[data, {1, r, r^2}, r] // Factor
Show[ListPlot[data, Axes -> False, Frame -> True,
FrameLabel -> {"MaxRecursion", "Number of evaluation points "},
PlotLabel -> StandardForm@"Plot[x,{x,-\[Pi],\[Pi]}]"],
Plot[f, {r, 0, 15}, PlotRange -> All]]
=> (100 + 3 r + r^2)/2
=> <Graphics>
One can see that the number of evaluation points for function f(x)=x
grows as (100 + 3 r + r^2)/2 where 'r' is the value of option
MaxRecursion.
It is clear that in the case of f(x)=x it is not necessary to go
deeper in recursion because the bend angle between successive segments
of the
approximating polyline in this case is always approximately equal to
zero. In Mathematica 5.2 Plot does no recursion in this case:
In[1]:=
l[div_]:=Length@Reap[Plot[Sow[x];x,{x,-Pi,
Pi},PlotDivision\[Rule]div,DisplayFunction\[Rule](#&)]][[2,1]]
Table[l[div],{div,1,10}]
Out[2]=
{25,25,25,25,25,25,25,25,25,25}
Why in Mathematica 7 Plot makes these superfluous evaluations? Is it
possible to force it to behave like Plot in version 5.2?