Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

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

Search the Archive

Re: Help with FindRoot

  • To: mathgroup at
  • Subject: [mg39861] Re: [mg39830] Help with FindRoot
  • From: Andrzej Kozlowski <akoz at>
  • Date: Sun, 9 Mar 2003 05:26:57 -0500 (EST)
  • Sender: owner-wri-mathgroup at

If you use sufficient WorkingPrecision and a reasonable starting point 
than you will be able to get rid of the tiny complex part with Chop. Eg:

FindRoot[3*x^4 - 46 + I*(x - 2) == 2, {x, 1}]

{x -> 2.0000000005164145 - 3.195328365745672*^-10*I}

Chop[FindRoot[3*x^4 - 46 + I*(x - 2) == 2, {x, 1},
    WorkingPrecision -> 30]]


Of course you can simply get rid of the unwanted small complex part 

FindRoot[3*x^4 - 46 + I*(x - 2) == 2, {x, 1}] /.
   Complex[a_, b_]/;b<10^-8 -> a


This get rids of the imaginary part if it is less than 10^-8.
There is however no way to make Mathematica "look for" real solutions 
in such cases, since there no purely numerical way to distinguish a 
"real" solution from a complex one with a very small imaginary part.

Andrzej Kozlowski
Yokohama, Japan

On Saturday, March 8, 2003, at 04:48  pm, Stefano Fricano wrote:

> Dear friend,
> I've problem with FindRoot[lhs==rhs, {x, x0}] .
> The description of the function in Help suggest that,
> if lhs and rhs are real then x will be real;
> if lhs and/or rhs are complex the x likely will be complex;
> if lhs and rhs are real but you want also x be complex then you
> need to add "+0.I" to lhs or rhs.
> My problem is that lhs is complex, rhs is real and I want only real
> solutions for x.
> How can I do it? How say to Mathematica to look for only real solution?
> Thanks
> This email has been scanned by RAV antivirus on server 

  • Prev by Date: Re: Conclusion: Mathematica will output plain text
  • Next by Date: Re: Symbols and Lists
  • Previous by thread: RE: Help with FindRoot
  • Next by thread: Conclusion: Mathematica will output plain text