MathGroup Archive 1999

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

Search the Archive

RE: Precision Problems

  • To: mathgroup at
  • Subject: [mg19239] RE: [mg19210] Precision Problems
  • From: "Ersek, Ted R" <ErsekTR at>
  • Date: Wed, 11 Aug 1999 02:06:51 -0400
  • Sender: owner-wri-mathgroup at

Holger Strauss  wrote:

I have some numerical precision problems (Mathematica 3.0)
with the following code:

f3[x_] := (*....<snip>.....*)

LogLinearPlot[f3[x], {x,0.05,Pi}]

As can be seen from the plot, evaluating f3 doesn't work for
small arguments. It seems to me that this is the result of large
numbers being subtracted from each other resulting in a very
small difference.
It it possible to increase the precision of the calculation adequatly?
I already tried to encapsulate the whole function with N[..., 50000],
however, without success...
Is there any other way of successfully evaluating and plotting
f3 for small arguments?


That isn't enough to force the use of arbitrary precision arithmetic.

On page 142 of The Mathematica Book (4th edition) it says 
"If the function you are plotting requires higher-precision operations, you
may have to switch off compilation in Plot.  You can do this by setting the
option Compiled->False".  Well LogLinearPlot has a Compiled option.



use the option Compiled->False.  Try it and you will see it doesn't make a
difference.  In fact it contrary to what the book says (Compiled->False)
doesn't make Plot use arbitrary precision either!

One must be more clever than that to force the use of arbitrary precision.
The code below will solve your problem.


f3[x_] := 20 Log[10,
  1/(15120 x^4)*
  (-90720 - 15120 x^2 + 13424 x^4 +
     9(13440 + 2240  x^2 + 257 x^4) Cos[x]-
     72(420 + 70  x^2 + 9 x^4) Cos[2x]+
      31 x^4 Cos[3x]



I wrote a package that will do everything Plot can do, except with arbitrary
precision arithmetic.  Programming the function so you can do things like
plot a list of functions with different styles was not at all easy!  The
package is available at:

Included with the package is extensive discussion on how and why it works.

I hope the plot functions in a future version will allow us to use a simple
option to force the use of arbitrary precision.

Ted Ersek

  • Prev by Date: Importing graphics into mathematica-Addition
  • Next by Date: Re: Mathematica Link for Excel and Excel 2000
  • Previous by thread: Precision Problems
  • Next by thread: Re: Precision Problems