MathGroup Archive 2005

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

Search the Archive

Re: Testing the 'type' of a root returned by Solve

  • To: mathgroup at
  • Subject: [mg54666] Re: Testing the 'type' of a root returned by Solve
  • From: Peter Pein <petsie at>
  • Date: Fri, 25 Feb 2005 01:19:29 -0500 (EST)
  • References: <cvk4i5$dgq$>
  • Sender: owner-wri-mathgroup at

Mike Witt wrote:
> If I solve an equation in which the solutions turn out
> to be functions of some variable, I can't figure out how
> to pick out one of the roots based on whether the root is
> real or complex.
> The problem is that Head[] reports that the roots are
> all "Times" because of the variable in them.
> The following notebook demonstrates. Can someone tell me
> the right way to do this (or point me to the right place
> in the book or help pages?)
> For private email remove the NOSPAM.
> -Mike
> <notebook snipped>

Hi Mike,

  hopefully you've got no imaginary feet ;-)

Select[r /. N[Solve[20*Feet^3 == (4*Pi*r^3)/5, r]],
   Simplify[Im[Chop[#1]], Feet \[Element] Reals] == 0 & ]

{1.99647 Feet}

is one possibility.

Or - if you prefer exact values:

   Select[r /. Solve[20*Feet^3 == (4*Pi*r^3)/5, r],
     ComplexExpand[Im[#1]] == 0 & ]
Peter Pein

  • Prev by Date: Re: personalizing Mathematica output
  • Next by Date: Re: Plots for publishing
  • Previous by thread: Notebook 'suddenly' does not talk to Kernel
  • Next by thread: Re: Testing the 'type' of a root returned by Solve