Re: system of simultaneous equations

• To: mathgroup at smc.vnet.net
• Subject: [mg22948] Re: [mg22895] system of simultaneous equations
• From: "Tomas Garza" <tgarza at mail.internet.com.mx>
• Date: Fri, 7 Apr 2000 02:54:31 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```David Braunholtz wrote:

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

Bear in mind that Solve gives solutions in terms of rules of the form x ->
sol. To give an example, let

In[1]:=
r := Random[Integer, {1, 9}];

In[2]:=
sols = Solve[
r x + r y + r z == r && r x + r y + r z == r &&
r x + r y + r z == r, {x, y, z}] // Flatten
Out[2]=
{x -> 4, y ->-49/3, z -> 25/3}

This is a list of rules, each giving the value of the corresponding
variable. Each member of this list is a list, too. For example,

In[3]:=
sols[[1]]
Out[3]=
x -> 4

and

In[4]:=
sols[[1, 2]]
Out[4]=
4

If you want a list of just the numerical values of the solutions, take

In[5]:=
vals = #[[2]] & /@ sols
Out[5]=
{4,-49/3, 25/3}

and if you want to pick only the positive ones, use Select:

In[3]:=
Select[vals, # > 0 &]
Out[3]=
{4, 25/3}

Tomas Garza
Mexico City

```

• Prev by Date: RE: 2-D Vector Field scale ?
• Next by Date: Re: Apparently easy ODE
• Previous by thread: Re:system of simultaneous equations
• Next by thread: Edit Mathematica graphics in Adobe