MathGroup Archive 1999

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

Search the Archive

Re: Real roots and other assumptions...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19921] Re: Real roots and other assumptions...
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Tue, 21 Sep 1999 02:22:52 -0400
  • References: <7s3p1u$ck5@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Janus Wesenberg <jaw at imf.au.dk> wrote in message
news:7s3p1u$ck5 at smc.vnet.net...
> Hi,
> I keep encountering problems of the following type when using mathematica:
> I want to solve some equation(s) under some assumptions about the
unknown(s),
> e.g. find the real roots of (x-1)(x^2+1).
> I've tried Solve[{Im[x]==0,(x-1)(x^2+1)==0},x]] for the above problem, but
that
> doesn't get me anywhere.
>
> Is there a general way to let Mathematica know about such additional
bounds as
> non-complexness etc? -- if so I would be happy to know it!
>
> Janus Wesenberg
> Student of Physics.
>
> PS. I'm using Mathematica from a HP-UX 10 system, and the notebook
interface
> have grave difficulties handling large expressions (they scrambled to
complete
> nonsense). The local system administrator just says "Use the text access",
but
> does anyone know how to make the notebook interface work?
>

Janus,

Cases[Solve[(x - 1)(x^2 + 1) == 0, x],
  s_ /; FreeQ[s, _Complex]]

    {{x -> 1}}

But there could be problems with precision and also with rules like

    x -> (a - I)(a + I)      (*which may, depending on a, give real
solutions but would be excluded*)

    x-> (1-e)^{1/3)        (* gives a complex solution, but would not be
excuded*)

We can improve things using N and ExpandAll, but we can also use Simplify.
The following tries to keep those solutions which may be real for some
parameter values.

RealSolve[eqs_, vars_, elims_List:{}, ass___] :=
  DeleteCases[
    Solve[eqs, vars, elims],
    s_ /; Or @@ (Simplify[Im[Last[#]] != 0,
                ass] & /@ s)]

RealSolve[(x - 1)(x^2 + 1) == 0, x, {}]

{{x -> 1}}

RealSolve[(x - p)(x^2 + 1) == 0, x, {}]

{{x -> p}}

RealSolve[(x - p)(x^2 + q^2) == 0, x, {}]

{{x -> p}, {x -> -I*q}, {x -> I*q}}

because

% /. q -> I

{{x -> p}, {x -> 1}, {x -> -1}}


Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565








  • Prev by Date: Re: Solving equations involving Ln function
  • Next by Date: Plotting Intervals on the numberline
  • Previous by thread: Re: Real roots and other assumptions...
  • Next by thread: Re: Real roots and other assumptions...