Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Plotting with arbitary precision????

  • To: mathgroup at
  • Subject: [mg69626] Re: Plotting with arbitary precision????
  • From: Paul Abbott <paul at>
  • Date: Sun, 17 Sep 2006 22:46:10 -0400 (EDT)
  • Organization: The University of Western Australia
  • References: <eejaoo$3q4$>

In article <eejaoo$3q4$1 at>,
 "lcw1964" <leslie.wright at> wrote:

> However, the problem comes with the plotting. In a very good rational
> approximation for Exp[x] I have a maximum relative error of, say, about
> 10^-22. Let's call it RatApp. If I try to plot (RatApp-Exp[x])/Exp[x]
> on my interval of approximation, I don't get a nice smooth double
> ripple error curve like I should. I get a noisy mess confined to
> about +/- 10^-17. Which is precisely what I should get since Plot uses
> only machine precision (not the 30 or so digits of arbitary working
> precision specified) when generating plots. Since the numerator of my
> error function will differ only in the 22nd digit or so and beyond,
> the subtlety of the subtraction is lost.
> Online help for Plot doesn't seem to provide an arbitrary precision
> "override" to get over this issue. In the other system, one simply had
> to increase the Digits setting since everything is done in software
> floating point anyway--slower, but easier to use. Is there any way in
> Mathematica to plot a function that requires such high precision in
> interim calculations so that the plot is accurate?

This is (almost) a FAQ -- look up 

  high precision plotting


and you will get a number of hits. 

As a simple example, if 

  f[x_] = LegendreP[50, x]

then machine precision is insufficient for plotting:

  Plot[f[x], {x, -1, 1}, PlotRange -> All, PlotPoints -> 50];

The trick is to re-define the function as

  g[x_?NumericQ] := With[{q = SetPrecision[x, 30]}, f[q]] 

  Plot[g[x], {x, -1, 1}, PlotRange -> All, PlotPoints -> 50];

In a future version of Mathematica I expect that there will be a 
WorkingPrecision option to Plot ...


Paul Abbott                                      Phone:  61 8 6488 2734
School of Physics, M013                            Fax: +61 8 6488 1014
The University of Western Australia         (CRICOS Provider No 00126G)    

  • Prev by Date: Re: Plotting with arbitary precision????
  • Next by Date: Re: Why is the negative root?
  • Previous by thread: Re: Plotting with arbitary precision????
  • Next by thread: question about DiracDelta