Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

Re: Solving simultaneous equations with inequalities

  • To: mathgroup at smc.vnet.net
  • Subject: [mg31151] Re: [mg31140] Solving simultaneous equations with inequalities
  • From: Andrzej Kozlowski <andrzej at bekkoame.ne.jp>
  • Date: Sun, 14 Oct 2001 04:11:43 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

It's hard to tell what you want with this amount of information. Do you 
mean something like this:

In[1]:=
Solve[{x^2+y^2==4,x^2-y^2==1},{x,y}]

Out[1]=
{{x -> -Sqrt[5/2], y -> -Sqrt[3/2]},
   {x -> -Sqrt[5/2], y -> Sqrt[3/2]},
   {x -> Sqrt[5/2], y -> -Sqrt[3/2]},
   {x -> Sqrt[5/2], y -> Sqrt[3/2]}}

You can get only solutions with x>0 by using Select (or Cases) like this:

In[5]:=
Select[Solve[{x^2+y^2==4,x^2-y^2==1},{x,y}],(x/.#)>0&]

Out[5]=
{{x -> Sqrt[5/2], y -> -Sqrt[3/2]}, {x -> Sqrt[5/2],
    y -> Sqrt[3/2]}}

or if you want both x any y to be positive:

In[2]:=
Select[Solve[{x^2+y^2==4,x^2-y^2==1},{x,y}],
   And@@(({x>0,y>0}/.#))&]

Out[2]=
{{x -> Sqrt[5/2], y -> Sqrt[3/2]}}

There is no way to do it using Solve alone, and for a good reason, for 
in general it takes just as long to find the solutions with x>0 as it 
takes to find all solutions. However, if you are only interested in real 
solutions you can get your answer with InequalitySolve:

In[3]:=
<<Algebra`InequalitySolve`

In[4]:=
InequalitySolve[{x^2+y^2==4,x^2-y^2==1,x>=0},{x,y}]

Out[4]=
x == Sqrt[5/2] && (y == Sqrt[3/2] || y == -Sqrt[3/2])

In[5]:=
InequalitySolve[{x^2+y^2==4,x^2-y^2==1,x>=0,
     y>=0},{x,y}]

Out[5]=
x == Sqrt[5/2] && y == Sqrt[3/2]

Note however that this is actually slower than using Solve and Select.

Andrzej Kozlowski
Toyama International University
JAPAN
http://platon.c.u-tokyo.ac.jp/andrzej/

On Saturday, October 13, 2001, at 03:47  PM, Timie Milie wrote:

> I am solving some simultaneous equations and getting four results 
> because
> the solution contains two square roots - produced because some of the
> equations to solve are of the form x^2 = y^2 + z^2. Is there any way of
> including the hint x>0 or 'I only want positive roots of x to be used' 
> in
> Solve[]?
>
> P.S. I'm not actually solving for x, it gets eliminated in the result.
>
> milstead at cs.bris.ac.uk
>
>
>
>
>



  • Prev by Date: Re: How do I eliminate premultipliers of "1." ?
  • Next by Date: Re: Using NDSolve for 2-variables function ?
  • Previous by thread: Re: Solving simultaneous equations with inequalities
  • Next by thread: Recursive Rules