MathGroup Archive 2004

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

Search the Archive

Re: Beware of NSolve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50189] Re: Beware of NSolve
  • From: carlos at colorado.edu (Carlos Felippa)
  • Date: Thu, 19 Aug 2004 06:28:28 -0400 (EDT)
  • References: <cfv4e4$8j0$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote in message news:<cfv4e4$8j0$1 at smc.vnet.net>...
> On 18 Aug 2004, at 07:20, Carlos Felippa wrote:
> 
> > Run v. 4.2 on Mac:
> >
> > f=5/432 - 11/(27*Sqrt[70]*Sqrt[19 - 1890*x]) + x/(2*Sqrt[38/35 - 
> > 108*x]);
> >
> >  Solve[f==0,x]  returns 2 real roots:
> >
> > {{x -> (-171 - 25*Sqrt[105])/30240}, {x -> (-171 + 
> > 25*Sqrt[105])/30240}}
> >
> > NSolve[f==0,x]  returns 4 real roots:
> >
> > {{x -> -0.10481082961146104}, {x -> -0.014126116704662378},
> >  {x -> 0.002816592895138556}, {x -> 0.0003796126802330315}}
> >
> > Roots 1 and 4 are incorrect.  (Just plot f)
> >
> > Had a similar problem with a quartic 3 months ago.  This is a
> > simpler example.
> >
> >
> >
> In this case as in many others involving numerical compoutations it is 
> just the question of the working precision. This is just a "fact of 
> life" of numerical mathematics
> 
> 
> f = 5/432 - 11/(27*Sqrt[70]*Sqrt[19 - 1890*x]) +
>      x/(2*Sqrt[38/35 - 108*x]);
> 
> 
> NSolve[f == 0, x]
> 
> Out[25]=
> {{x -> -0.1048108296114584},
>    {x -> -0.014126116704662336},
>    {x -> 0.0028165928951385585},
>    {x -> 0.0003796126802330329}}
> 
> 
> but
> 
> 
> NSolve[f == 0, x, WorkingPrecision -> 100]
> 
> 
> {{x -> -0.01412611670466236638824490631656833001879549658\
> 023713039810018063813686176066910885658666635943993612512\
> 76942823094`99.69897000433602},
>    {x -> 0.00281659289513855686443538250704452049498597277\
> 071332087429065682861305223685958504706285683563041231560\
> 38847579695`99.69897000433602}}
> 
> 
> 
> 
> Andrzej Kozlowski
> Chiba, Japan
> http://www.mimuw.edu.pl/~akoz/

Yes, precision is the evil of all roots.  Here is a tiny variation on my
example:

f=5/432-11/(27*Sqrt[70]*Sqrt[19-1890*x])+x/(2*Sqrt[38/35-(108+1/100)*x]);
Print[NSolve[f,x,16]];  (* gives 6 roots *)
Print[NSolve[f,x,24]];  (* gives 4 roots *)
Print[NSolve[f,x,32]];  (* gives 2 roots *)
Print[NSolve[f,x,64]];  (* gives 3 roots *)

(Please DONT e-mail to my address)


  • Prev by Date: Technical Publishing Made Easy with New Wolfram Publicon Software
  • Next by Date: Wolfram Research présente sa première conférence Mathematica à Paris
  • Previous by thread: Re: Beware of NSolve
  • Next by thread: Re: Beware of NSolve