Re: NSolve with conditions
- To: mathgroup at smc.vnet.net
- Subject: [mg20086] Re: NSolve with conditions
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Thu, 30 Sep 1999 02:43:04 -0400
- References: <7ssfgd$bkj@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Alphons,
The following examples may help.
sol = NSolve[{x^2 - ((y^2 + 1)y) == 0, x^2 == 1}, {x, y}]
{{x -> 1., y -> -0.34116390191400997 +
1.1615413999972526*I}, {x -> -1.,
y -> -0.34116390191400997 + 1.1615413999972526*I},
{x -> 1., y -> -0.34116390191400997 -
1.1615413999972526*I}, {x -> -1.,
y -> -0.34116390191400997 - 1.1615413999972526*I},
{x -> 1., y -> 0.6823278038280198},
{x -> -1., y -> 0.6823278038280198}}
Cases[sol,
sl_ /; (And[x > 0, y > 0] /. sl),
{1}
]
{{x -> 1., y -> 0.6823278038280198}}
You will get some warning messages about inequalities with complex numbers;
these can be suppressed by first entering
Off[Greater::"nord"]
and turned back on with
On[Greater::"nord"]
In case symbolic solution is possible we can use InequalitySolve:
<< Algebra`InequalitySolve`
insol = InequalitySolve[{x^2 - ((y^2 + 1)y) == 0, x^2 == 1, x > 0, y > 0},
{x,
y}]
x == 1 && y == Root[-1 + #1 + #1^3 & , 1]
N[insol]
x == 1. && y == 0.6823278038280193
ToRadicals[insol]
x == 1 && y == -(2/(3*(9 + Sqrt[93])))^(1/3) +
(1/2*(9 + Sqrt[93]))^(1/3)/3^(2/3)
--
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
Alphons Fakler <fakler at chemsens.pharma.ethz.ch> wrote in message
news:7ssfgd$bkj at smc.vnet.net...
> Hello,
>
> I'm trying to solve a system of linear equations by NSolve. How can I
> restrict the solutions, to a subset, that machtes given conditions.
>
> e.g.:
> GlgSys = {EDTAtot == 0.002,
> EDTA1 == 10^10.26*EDTA*H,
> EDTA2 == 10^6.61*EDTA1*H,
> EDTA3 == 10^2.76*EDTA2*H,
> EDTA + EDTA1 + EDTA2 + EDTA3 == EDTAtot,
> H + 2*EDTAtot == 10^(-14)/H + 2*EDTA2 + 3*EDTA1 + EDTA3 + 4*EDTA};
>
> Following conditions should be kept:
> 0<= EDTA <= 0.002,
> 0<= EDTA1 <= 0.002,
> 0<= EDTA2 <= 0.002,
> 0<= EDTA3 <= 0.002,
> 0<= H <= 10^(-4)
>
> Thanks for your reply
>
>
> --
> Alphons Fakler
> Zentrum fur Chemische Sensoren
> ETH Technopark
> Technoparkstr. 1
> CH - 8005 Zurich
> Tel. (01) 445-1492
> Fax: (01) 445-1233
> EMail: fakler at chemsens.pharma.ethz.ch
>
>
>