Re:system of simultaneous equations

*To*: mathgroup at smc.vnet.net*Subject*: [mg22919] Re:[mg22895] system of simultaneous equations*From*: Leopoldo Yanes & Mariela Sanchez <leoymary at planetall.com>*Date*: Thu, 6 Apr 2000 02:04:35 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

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 ----------------------------------