Re: Plot[x Sin[x],{-100,100}] Bad {-100,99} Good?
- To: mathgroup at smc.vnet.net
- Subject: [mg38313] Re: Plot[x Sin[x],{-100,100}] Bad {-100,99} Good?
- From: Tom Burton <tburton at brahea.com>
- Date: Thu, 12 Dec 2002 01:32:41 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 12/10/02 1:46 AM, in article at4d54$etu$1 at smc.vnet.net, "Steven T. Hatton" <hattons at globalsymmetry.com> wrote: > This is Mathematica 4.2 on Linux. I evaluated Plot[x Sin[x], {-100,100}] and > disvovered that the portion of the plot between,9.5Pi and 11Pi is displayed > as a line segment joining the points {9.5 , 9.5 Sin[9.5]} and {11 , 11 > Sin[11]}. I've also found that the plot from x=-100 to x=99.99 is incorrect. > The plot over the range [-100,99] is correct. What is happening here? Does > this happen on other systems? > -- Although Mathematica attempts to refine the plot recursively as needed to produce an accurate plot, you can fool the algorithm. One way is to provide a function with more oscillations than the initial number of PlotPoints. On my system (4.2 on Mac), the default initial number of PlotPoints is 25. Your function oscillates about 32 times over the domain. Increase the number of PlotPoints to 50. The problem goes away. As you have seen, fewer PlotPoints may work, depending upon the initial distribution of points. Plot your examples with PlotDivision->1 to see that small adjustments in the domain change the number of oscillations captured by the initial set of points. Tom Burton