Re: Solve real roots only ?

• To: mathgroup at smc.vnet.net
• Subject: [mg43619] Re: Solve real roots only ?
• From: Paul Abbott <paul at physics.uwa.edu.au>
• Date: Tue, 23 Sep 2003 04:02:50 -0400 (EDT)
• Organization: The University of Western Australia
• References: <bkm7jh\$rgu\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```In article <bkm7jh\$rgu\$1 at smc.vnet.net>,
Pavel Pokorny <Pavel.Pokorny at vscht.cz> wrote:

> how can I tell Solve to find real roots only?
> I tried RealOnly but it makes this little program to crash!
>
>    Needs["Miscellaneous`RealOnly`"];
>    f = a - (1-x) Sqrt[20 x - 20000 y];
>    g = (a(1-y)- 1000 y (1-x))/(10-x);
>    s = Solve [ f==0 && g==0, {x,y}];
>    xs = x /. s;
>    xx = Series [xs, {a,0,2}];

Since it looks like you want to compute a series expansion, in the
parameter a, here is one way to proceed:

Tell Mathematica that you don't want to see explicit radicals:

SetOptions[Roots, Cubics -> False, Quartics -> False];

f = a - (1 - x) Sqrt[20 x - 20000 y];
g = (a (1 - y) - 1000 y (1 - x))/(10 - x);

We want to compute series expansions for x and y in terms of the
parameter a, so we make x and y explicitly depend on a:

{f,g} = {f,g} /. {x -> x[a], y -> y[a]}

Set the expansion order:

order = 3;

Use coercion to force the series expansion (adding the O[a] term) and
then solve for the undetermined expansion coefficients:

RootReduce[SolveAlways[{0, 0} == {f, g} + O[a]^order, a]]

Substitute the coefficients back into the series expansions for x and y:

RootReduce[Normal[{x[a], y[a]} + O[a]^order /. %]]

This result is exact. Compute numerically, if desired:

N[%]

Cheers,
Paul

--
Paul Abbott                                   Phone: +61 8 9380 2734
School of Physics, M013                         Fax: +61 8 9380 1014
The University of Western Australia      (CRICOS Provider No 00126G)
35 Stirling Highway
Crawley WA 6009                      mailto:paul at physics.uwa.edu.au
AUSTRALIA                            http://physics.uwa.edu.au/~paul

```

• Prev by Date: Re: Forcing a Fit through a Data Point (Mathematica 5)
• Next by Date: Re: Proper way to free memory?
• Previous by thread: Re: Solve real roots only ?
• Next by thread: Forcing a Fit through a Data Point (Mathematica 5)