MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Weird Plot problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59881] Re: Weird Plot problem
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Wed, 24 Aug 2005 06:32:19 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 8/23/05 at 5:17 AM, h.l.owen at dl.ac.uk (Owen, HL (Hywel)) wrote:

>>The simplest solution is to increase the number of points where
>>Mathematica samples the function to be plotted, i.e., using
>>PlotPoints->n where n is something larger than the default. But
>>this is not the only solution. Any change in the plot parameters
>>that causes Mathematica to sample at different points can
>>potentially solve the problem. And if the function is time
>>consuming to evaluate, it *may* be preferable to do something
>>other than simply increase the value for PlotPoints. For example,
>>changing {x,-5, 5} to {x, -5.01, 5.01} will cause Mathematica to
>>sample the function at different points and likely will resolve
>>the issue.

>Yes, that was my fix too. The thing that confused me was that part
>of the plot looked fine whilst only one section had gone haywire. I
>think I'll stick to ListPlot!

Using ListPlot is no magic cure for the problem. For example, consider

ListPlot[Table[x + Sin[2 Pi x], {x, 0, 26}]];

No evidence of oscillation in that set of points.

or how about

ListPlot[Table[
    x + Abs[x - 0.959]^(-0.01), {x, 0, 2, 0.1}]];
    
The singularity at 0.959 is missed

In both of these examples, I've used simple expressions that are easy to analyze and see where the problem is. In general, expressions you want to plot aren't so easy to analyze. If the expression is sufficiently complex, simply sampling at uniform intervals may not be adequate to see singularities or oscillations. 

The advantage of your selecting the sample points over Mathematica's adaptive sampling algorithm occurs when you know quite a bit about the expression. You can avoid or highlight problem areas.

OTOH, the adaptive sampling algorithm Mathematica uses is just as likely if not more likely to find ill behaved portions of the expression when nothing or little is known.

The issue of how to choose the intial set of points to sample an expression and when to add more points to the initial sample is far from trivial. When you think about it, it should not be surprising Plot fails to accurately represent the expression in some cases. Instead, the real surprise is that it works as well as it does so often.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Does ContourPlot behave correctly?
  • Next by Date: Re: ever gotten SVG Export to work?
  • Previous by thread: Re: Re: Weird Plot problem
  • Next by thread: Random sampling of an arbitrary distribution