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

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

```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 ;-)

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

Out=
{1.99647 Feet}

is one possibility.

Or - if you prefer exact values:

In:=
Select[r /. Solve[20*Feet^3 == (4*Pi*r^3)/5, r],
ComplexExpand[Im[#1]] == 0 & ]
Out=
{(5^(2/3)*Feet)/Pi^(1/3)}
--
Peter Pein
Berlin

```

• 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