MathGroup Archive 1998

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

Search the Archive

Re: FindRoot accuracy/precision



Hi Michael,

Concerning your question about how to make FindRoot work at higher
precision, you do need to increase the WorkingPrecision of FindRoot.
But, you also need to make sure everything inside FindRoot is of the
same precision. One not recommended way to do this is to use
SetPrecision to change the precision, i.e.,

SetPrecision[eq1, precision]

where precision is your desired precision. Although this will work, the
extra precision is of course random. A better approach is to generate
your eq1 more precisely to start with. You also need to be careful with
machine numbers in your symbolic equations, i.e.,

Sin[ x^(1/2) ]

is better than

Sin[ x^0.5 ]

Good luck

Carl Woll
Dept of Physics
U of Washington

On Mon, 2 Mar 1998, Michael Chang wrote:

> Hallo!
> 
> I'm running Mathematica 3.0 on a PC (with Windows 95).
> 
> I'm trying to use FindRoot to solve the roots for *seven* nonlinear
> equations with seven variables.  I use Random to generate seven
> (positive real) initial starting points for FindRoot, and continuously
> run FindRoot until seven candidate (positive real) roots are found. 
> 
> The basic text is as follows:
> 
> ok=0; While[ok==0,
> ans=FindRoot[eq1==eq2,{x1,Random[Real,x1upper]},
> {x2,Random[Real,x2upper]}, (etc.)]; If[Min[ans]>=0, ok=1; Print[ans]]]
> 
> In the above text, eq1 is a list of numerical values, and eq2 is a list
> of symbolic equations. The problem is that when evaluated (i.e.
> eq2/.ans), only *one* of my seven equations appears `close' in value;
> this particular equation also yields the largest numerical value
> (4*10^2), while the other values should get smaller (all the way down
> to 10^-13).  (I know that this large spread in values is part of my
> problem.)
> 
> So ... how can I get Mathematica to FindRoots more accurately?  My
> $MachinePrecision is 16 (which cannot be changed, I believe). 
> Precision of eq1 (my numerical values) only seems to be 16.  Is this my
> problem (i.e. should this be infinity)?  I've tried changing
> WorkingPrecision in FindRoots, but this doesn't seem to have any
> effect! 
> 
> In essence, I'm trying to find out how the result of FindRoot can yield
> 
> eq1 (approximately=) eq2/.ans
> 
> Currently, this does *not* occur except for the first element of my
> list.  The other elements are sometimes one+ order of magnitude off and
> are decreasing in magnitude to order(10^-13).
> 
> I'd be grateful for any and all suggestions/advice concerning this
> pressing problem of mine!
> 
> Thanks in advance!
> 
> Mike
> 
> 




  • Prev by Date: RE: are nested patterns imposs
  • Next by Date: Re: Question about Mathematica
  • Prev by thread: Re: Re: Re: FindRoot accuracy/precision
  • Next by thread: Re: Re: Re: FindRoot accuracy/precision