Re: Help with FindRoot

*To*: mathgroup at smc.vnet.net*Subject*: [mg39861] Re: [mg39830] Help with FindRoot*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>*Date*: Sun, 9 Mar 2003 05:26:57 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

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} but Chop[FindRoot[3*x^4 - 46 + I*(x - 2) == 2, {x, 1}, WorkingPrecision -> 30]] {x->2.00000000000000000000000000000} Of course you can simply get rid of the unwanted small complex part "manually": FindRoot[3*x^4 - 46 + I*(x - 2) == 2, {x, 1}] /. Complex[a_, b_]/;b<10^-8 -> a {x->2.} 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 http://www.mimuw.edu.pl/~akoz/ http://platon.c.u-tokyo.ac.jp/andrzej/ 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 > dsfa.fisica.unipa.it > > >