MathGroup Archive 2000

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

Search the Archive

Re:system of simultaneous equations


Original Message:
While I've got the attention of a Mathematica expert, I am wanting to select a single root of a system of simultaneous equations (with positive values for all 3 variables) - and (being new to mathematica) cannot work out how to do this. I successfully get a list of roots, but cannot make the (you would think) easy step to reduce the list to only (positive) roots. Any help VERY gratefully received. I have searched in Mathgroup at Wolfram without finding anything.
Cheers
David Braunholtz

Reply:

David,
	For simplicity, suppose your system has 1 equation in y and you have parameters a,b,c,etc. Also assume that your equation can have either 3 or 2 solutions depending on parameter values. You could define a program similar to:

Name[A_, B_, C_, OTHERPARAMETERS_] := Module[{a, b, c, otherparameters}, a = A; b=B; c=C; otherparameters=OTHERPARAMETERS; 

x = NSolve[{LHS1 == RHS1 }, {y}];
( Here you will obtain a list of the form {y1->#, y2-># ,y3->#} or {y1->#, y2->#} )

If[Length[x] == 3,
x = {y /. Part[x, 1], y /. Part[x, 2], y /. Part[x, 3]};                     
If[Head[Part[x, 3]] === NonPositive, x = Drop[x, {3}], x];
If[Head[Part[x, 2]] === NonPositive, x = Drop[x, {2}], x];
If[Head[Part[x, 1]] === NonPositive, x = Drop[x, {1}], x],

(At the end of this procedure, you get a list with all positive numbers (if you happened to have 3 solutions) , otherwise see below...)

x = {nf /. Part[x, 1], nf /. Part[x, 2]};
If[Head[Part[x, 2]] === NonPositive, x = Drop[x, {2}], x]; 
If[Head[Part[x, 1]] === NonPositive, x = Drop[x, {1}], x]]]

(At the end of this "otherwise" procedure, you get again a list with positive numbers). In the case of multiple equations you can make the chages accordingly (notice that you would need to change the list dimension). 

All the best,
Leo.
----------------------------------
Leopoldo Yanes
PhD Programme
Department of Economics
London School of Economics

Emails, LSE:	L.J.Yanes at lse.ac.uk
	      Permanent:	Leoymary at planetall.com
----------------------------------




  • Prev by Date: Maxim Rytin / Champernowne
  • Next by Date: Re: A faster Divisors function
  • Previous by thread: Re: system of simultaneous equations
  • Next by thread: Re: system of simultaneous equations