[Date Index]
[Thread Index]
[Author Index]
Re: Precision Problems
*To*: mathgroup at smc.vnet.net
*Subject*: [mg19232] Re: Precision Problems
*From*: "Allan Hayes" <hay at haystack.demon.co.uk>
*Date*: Wed, 11 Aug 1999 02:06:47 -0400
*References*: <7ookac$i3h@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Holger Strauss <strauss at ika.ruhr-uni-bochum.de> wrote in message
news:7ookac$i3h at smc.vnet.net...
> Hi,
>
> I have some numerical precision problems (Mathematica 3.0)
> with the following code:
>
> <<Graphics`Graphics`
> 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])]
> 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?
>
> Holger
>
Holger:
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])]
<< Graphics`Graphics`
For this example, when all the numbers in f3[x[ are exact we can use
LogLinearPlot[
f3[SetPrecision[x, 20]] (*SetPrecision[17] does not work*)
, {x, 0.05, Pi}, PlotRange -> All]
The point is, that the with N[f3[x],...] in place of f3[x] the plotting
function substitutes machine numbers for x; f3[x] is then computed
(innacurately), and N[.,nnn] cannot correct this. So we need to increase the
precision of the numbers that are substituted for x before f3 computes.
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
the function computes.
Prev by Date:
**RE: Command for Stopping Notebook Evaluation?**
Next by Date:
**New Mathematica Tutorial**
Previous by thread:
**RE: Precision Problems**
Next by thread:
**Memory bloat -- what have I done?**
| |