How do I extract the real part of a substitution expression from FindRoot or Solve? Or alternately, how do I insist that they return real results?

For example, FindRoot returns something of the form:

{x->A + B I}

Analytically, I know that x must be real. Because B is 17+ orders of magnitude smaller than A, I assume it's numerical slop.

If I do:

Re[FindRoot[expr, {x, guess}]]

it simply returns:

Re[{x->A + B I}]

Assumptions aren't helping:

Assuming[Element[x, Reals], FindRoot[expr, {x, guess}]] ]

still returns x with a small imaginary component. Any suggestions?

  • 3
    $\begingroup$ Use Chop, that's all. $\endgroup$
    – Artes
    Apr 14, 2015 at 16:35
  • 1
    $\begingroup$ This is surely a duplicate. Could we please close it as such rather than "easily found in the documentation?" $\endgroup$
    – Mr.Wizard
    Apr 14, 2015 at 18:58
  • $\begingroup$ Related: (5235), (17809), (52353), (60278) - The last one seems the closest duplicate, but I'm surprised there isn't an older one. $\endgroup$
    – Michael E2
    Apr 14, 2015 at 19:41
  • 1
    $\begingroup$ I did search before asking, but couldn't find anything after a few tries. Chop works, but I wouldn't say it's easy to find in the documentation unless you already know it's there... $\endgroup$
    – Paul T.
    Apr 15, 2015 at 21:21

1 Answer 1

Chop[FindRoot[expr, {x, guess}]]

Not the answer you're looking for? Browse other questions tagged or ask your own question.