Re: unwanted Complex result

• To: mathgroup at smc.vnet.net
• Subject: [mg91598] Re: unwanted Complex result
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Thu, 28 Aug 2008 07:39:49 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <g95k8a\$543\$1@smc.vnet.net>

```John Rivers wrote:

> Solve[
> (Sqrt[speed ^ 2 - windx ^ 2] + windy) / a speed ^ 2 + b speed + c ==
> distance / height
> , speed]
>
> this works but returns 4 solutions that all return complex numbers
>
> I need a real number

You could use either *Reduce[eqns, vars, Reals]* with a domain
specification (third argument) or *Cases[]* as in the following:

With[{windx = 10, windy = 2, a = 3, b = 5, c = 7, distance = 100,
height = 40},
Module[{eqn = (Sqrt[speed^2 - windx^2] + windy)/a speed^2 + b speed +
c == distance/height},
Print[N[Solve[eqn, speed]]];
Print[N[Reduce[eqn, speed, Reals]]];
Print[N[
Cases[Solve[eqn, speed],
s_ /; (Chop[Im[speed /. s]] == 0) -> s]]]]]

{{speed->-0.678225-0.300835 I},{speed->-0.678225+0.300835 I},
{speed->0.385283-1.72241 I},{speed->0.385283+1.72241 I}}

False

{}

Regards,
-- Jean-Marc

```

• Prev by Date: Re: unwanted Complex result
• Next by Date: Re: What am I doing wrong?
• Previous by thread: Re: unwanted Complex result
• Next by thread: Re: unwanted Complex result