MathGroup Archive 2009

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

Search the Archive

Re: simultaneous equations for chemical speciation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100209] Re: [mg100186] simultaneous equations for chemical speciation
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Thu, 28 May 2009 04:28:28 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

eqns = {
   a == b + c + d,
   e == f + g + c + 2 d,
   h == c/(b*g),
   i == d/(c*g),
   h*i == d/(b*g^2),
   j == m*g/f,
   k == l*m,
   n + m + b + c == g + l};

Length[eqns]

8

vars = Union[Cases[eqns, _Symbol, Infinity]]

{a,b,c,d,e,f,g,h,i,j,k,l,m,n}

Length[vars]

14

You have 8 eqns with 14 variables. Specify 6 variables to solve for.

(soln = Solve[eqns, Take[vars, {4, 9}]][[1]] // Sort) // Column

Union[Cases[Last /@ soln, _Symbol, Infinity]]

{a,b,c,j,l,m,n}

Length[%]

7

There are only 7 of the 8 remaining variables used so you can eliminate one variable

(soln2 = Solve[eqns, Take[vars, {5, 9}]][[1]] // Sort) // Column

Union[Cases[Last /@ soln2, _Symbol, Infinity]]

{b,c,d,j,l,m,n}

Length[%]

7


Bob Hanlon

---- Jem & Tracy <jemandtracy at bigpond.com> wrote: 

=============
Hi, I am a postgrad student and completely new to mathematica, I am just 
starting to realise the possibilities.

I am trying to do a chemical speciation calculation.
I have a set of simultaneous equations which represents the equilibria, 
mass balance, and charge balance in the system.

I want to eliminate some of the variables, and then be able to solve for 
the remaining ones.
My system of equations looks like this:
a=b+c+d
e=f+g+c+2d
h=c/(bg)
i=d/(cg)
hi=d/(bg^2)
j=mg/f
k=lm
n+m+b+c=g+l

Basically, I can solve for the variable I want, but I am having trouble 
eliminating the ones I don't want (ie. I am getting an answer that is in 
terms of the wrong variables)
Sofar my formula looks like:

Solve[{a == b + c + d, e == f + g + c + 2 d, h == c/(b*g),
  i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m,
  n + m + b + c == g + l}, {g}]

If I use a similar formula for the "Eliminate" function, I get error 
mesages.

I have been in the help files for ages, and don't really understand how 
to do this.
I would really appreciate some pointers!!
Thanks




  • Prev by Date: Re: list manipulation
  • Next by Date: Re: using predefined expressions in functions [newbie
  • Previous by thread: simultaneous equations for chemical speciation
  • Next by thread: Re: simultaneous equations for chemical speciation