MathGroup Archive 1997

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

Search the Archive

RE: problems with precision

  • To: mathgroup at smc.vnet.net
  • Subject: [mg7673] RE: [mg7646] problems with precision
  • From: Ersek_Ted%PAX1A at mr.nawcad.navy.mil
  • Date: Thu, 26 Jun 1997 01:36:57 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

A French student wrote;

|We had to calculate with high accuracy (more than 20 digits) the solution
|of a 2 dimensional non-linear system. The problem to solve was very easy.
|But Maple and Mathematica agreed only on the 15 first digits. I used the
|function SetPrecision. Is there another function to set calculus precision?
|
|Here is the listing of my routine in Mathematica :
|
|rr=Table[FindRoot[{x+Cos[y]*Sinh[x]==0,y+Sin[y]*Cosh[x]==0},{x,N[Abs[Cos[(2  
*p-1
|1)*Pi+Pi/4]]Sqrt[((2*p-1)*Pi+Pi/4/Sin[(2*p-1)*Pi+Pi/4]^2)-1]]},{y,(2*p-1)*P  
i+Pi
|i/4}]
|, {p, 1, 20, 1}]
|
|rr=SetPrecision[rr,20]
|

In the above FindRoot used MachinePrecision (the default precision).
Then SetPrecision was used to pad the binary form of the solution with 
enough
zeros so that it has 20 decimal digits of precision.  Note: after tacking on 
a bunch
of binary zeros we don't get a bunch of decimal zeros.

What we did is like weighing a mass in chem lab on a garden variety scale
and saying it weighs 34.1500000000000000002367 grams.

Now how do we get the desired answer.
First, try looking at the FindRoot Options.


In[1]:= Options[FindRoot]

Out[1]=  {AccuracyGoal->Automatic, Compiled->True, DampingFactor->1,
                 Jacobian->Automatic, MaxIterations->15, 
WorkingPrecision->16}


Now lets learn about WorkingPrecision.

In[2]:=  ?WorkingPrecision

Out[2]=  WorkingPrecision is an option for various numerical operations 
which
                 specifies how many digits of precision should be maintained 
in internal
                 computations.


The line below will give the right solution for one of the cases.


In[3]:=    soln =   FindRoot[
                        {x + Cos[y] * Sinh[x] == 0,   y + Sin[y] * Cosh[x] 
== 0},
                        {x, Abs[Cos[ -35 Pi /4 ] ]  Sqrt[Pi + (Pi/4) / Sin[5 
Pi/4]^2 - 1] },
                        {y, 5/4  Pi},
                  WorkingPrecision -> 25]


Ou[3]:=   { x-> 2.250728611601860542840015,
                    y-> 4.21239223049066060098377 }


But be careful you may need to use more than 20 digits of Working Precision 
to
get a solution with 20 digite of Precision.

Why?     Because  the  Precision of f[x]  is less than the Precision of  x
when the magnitude of f'[x]  is large.

The Options command is a very handy feature.  Especially for some of the 
graphics
commands.  For example try the following:

In[4]:=  Options[Plot]


          Ted Ersek
          ersek_ted%pax1a at mr.nawcad.navy.mil



  • Prev by Date: Mathematica Developer Conference 1997
  • Next by Date: Re: problems with precision
  • Previous by thread: Re: problems with precision
  • Next by thread: Re: problems with precision