```Path: news.mathworks.com!newsfeed-00.mathworks.com!solaris.cc.vt.edu!news.vt.edu!news.glorb.com!news2.glorb.com!tr22g12.aset.psu.edu!news.mathforum.org!not-for-mail
From: Torsten Hennig <Torsten.Hennig@umsicht.fhg.de>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Newton Raphson method for chemical equilibrium system
Date: Wed, 04 Aug 2010 10:55:44 EDT
Organization: The Math Forum
Lines: 25
Message-ID: <884701223.55417.1280933774596.JavaMail.root@gallium.mathforum.org>
References: <i3brpb\$2bi\$1@fred.mathworks.com>
NNTP-Posting-Host: gallium.mathforum.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: support1.mathforum.org 1280933774 21998 144.118.94.39 (4 Aug 2010 14:56:14 GMT)
X-Complaints-To: news@news.mathforum.org
NNTP-Posting-Date: Wed, 4 Aug 2010 14:56:14 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:658998

>
> Thanks Steve, but I can't read German.  I'm trying to
> solve the following system of equations:
> where: CH4 = N(1), H2O = N(2), CO = N(3), H2 = N(4),
> CO2 = N(5), O2 = N(6)
>
> CH4+CO+CO2-C = 0
> 4*CH4+2*H2O+2*H2-H = 0
> H2O+CO+2*CO2+2*O2-O = 0
> -LnKp1+2*log(P/sum(N))+log(N(3))+3*log(N(4))-log(N(1))
> -log(N(2)) = 0
> -LnKp2+log(N(5))+log(N(4))-log(N(3))-log(N(2)) = 0
> -LnKp3-0.5*log(P/sum(N))+log(N(2))-log(N(4))-0.5*log(N
> (6)) = 0
>
> Known inputs are LnKp, C, H, O.  Where LnKp is the
> log of the equilibrium constant for that particular
> reaction at the specified temperature.

The first thing I'd do is to substitute N(i) = N~(i)^2
for i=1,...,6 to avoid negative arguments within
the logarithm.

Best wishes
Torsten.
```