POLYMATH Report          NLE 
 Nonlinear Equations 2016-May-31 

Calculated values of NLE variables
    Variable Value f(x) Initial Guess Initial f(x)
1 C2H2 3.16E-10 2.6E-25 0.001 1.0E-03
2 C2H4 9.54E-08 -2.6E-13 0.001 6.5E01
3 C2H6 1.67E-07 -1.7E-13 0.001 8.4E01
4 CH4 0.066564 -6.7E-16 0.001 4.3E01
5 CO 1.38852 -1.6E-15 1 -6.3E00
6 CO2 0.544918 5.6E-15 0.993 -2.0E01
7 H2 5.34523 0.0E00 5.992 2.0E01
8 H2O 1.52165 -1.8E-15 1 4.6E00
9 lamda1 24.4197 0.0E00 10 -1.4E-02
10 lamda2 0.253059 0.0E00 10 0.0E00
11 lamda3 1.55983 0.0E00 10 0.0E00
12 O2 5.46E-21 -4.9E-27 0.0001 1.0E-04

    Variable Value Initial Value
1 R 1.9872 1.9872
2 sum 8.86687 8.9891

Nonlinear equations
1 f(lamda1) = 2 * CO2 + CO + 2 * O2 + H2O - 4 = 0
    Oxygen balance
2 f(lamda2) = 4 * CH4 + 4 * C2H4 + 2 * C2H2 + 2 * H2 + 2 * H2O + 6 * C2H6 - 14 = 0
    Hydrogen balance
3 f(lamda3) = CH4 + 2 * C2H4 + 2 * C2H2 + CO2 + CO + 2 * C2H6 - 2 = 0
    Carbon balance
4 f(H2) = ln(H2 / sum) + 2 * lamda2 = 0
5 f(H2O) = -46.03 / R + ln(H2O / sum) + lamda1 + 2 * lamda2 = 0
6 f(CO) = -47.942 / R + ln(CO / sum) + lamda1 + lamda3 = 0
7 f(CO2) = -94.61 / R + ln(CO2 / sum) + 2 * lamda1 + lamda3 = 0
8 f(CH4) = 4.61 / R + ln(CH4 / sum) + 4 * lamda2 + lamda3 = 0
9 f(C2H6) = 26.13 / R + ln(C2H6 / sum) + 6 * lamda2 + 2 * lamda3 = 0
10 f(C2H4) = 28.249 / R + ln(C2H4 / sum) + 4 * lamda2 + 2 * lamda3 = 0
11 f(C2H2) = C2H2 - exp(-(40.604 / R + 2 * lamda2 + 2 * lamda3)) * sum = 0
12 f(O2) = O2 - exp(-2 * lamda1) * sum = 0

Explicit equations
1 R = 1.9872
2 sum = H2 + O2 + H2O + CO + CO2 + CH4 + C2H6 + C2H4 + C2H2

Conditions for solution
lamda1 Any real value
lamda2 Any real value
lamda3 Any real value
H2 Any real value
H2O Any real value
CO Any real value
CO2 Any real value
CH4 Absolutely Positive
C2H6 Absolutely Positive
C2H4 Absolutely Positive
C2H2 Absolutely Positive
O2 Absolutely Positive

Problem source text
# S. 21* - NLE System
# Complex Chemical Equilibrium
# Verified Solution: C2H2=3.16E-10, C2H4=9.54E-8, C2H6=1.67E-7
# CH4=0.066564, CO2=0.544918, H2=5.34523, H2O=1.52165, CO=1.38852
# lamda1=24.4197, lamda2=0.253059, lamda3=1.55983, O2=5.46E-21
# Ref.:Prob. 4.5 in Problem Solving in Chemical...
R = 1.9872
sum = H2 + O2 + H2O + CO + CO2 + CH4 + C2H6 + C2H4 + C2H2
f(lamda1) = 2 * CO2 + CO + 2 * O2 + H2O - 4 # Oxygen balance
f(lamda2) = 4 * CH4 + 4 * C2H4 + 2 * C2H2 + 2 * H2 + 2 * H2O + 6 * C2H6 - 14 # Hydrogen balance
f(lamda3) = CH4 + 2 * C2H4 + 2 * C2H2 + CO2 + CO + 2 * C2H6 - 2 # Carbon balance
f(H2) = ln(H2 / sum) + 2 * lamda2
f(H2O) = -46.03 / R + ln(H2O / sum) + lamda1 + 2 * lamda2
f(CO) = -47.942 / R + ln(CO / sum) + lamda1 + lamda3
f(CO2) = -94.61 / R + ln(CO2 / sum) + 2 * lamda1 + lamda3
f(CH4) = 4.61 / R + ln(CH4 / sum) + 4 * lamda2 + lamda3
f(C2H6) = 26.13 / R + ln(C2H6 / sum) + 6 * lamda2 + 2 * lamda3
f(C2H4) = 28.249 / R + ln(C2H4 / sum) + 4 * lamda2 + 2 * lamda3
f(C2H2) = C2H2 - exp(-(40.604 / R + 2 * lamda2 + 2 * lamda3)) * sum
f(O2) = O2 - exp(-2 * lamda1) * sum
H2(0) = 5.992
O2(0) = 0.0001 > 0
H2O(0) = 1
CO(0) = 1
CH4(0) = 0.001 > 0
C2H4(0) = 0.001 > 0
C2H2(0) = 0.001 > 0
CO2(0) = 0.993
C2H6(0) = 0.001 > 0
lamda1(0) = 10
lamda2(0) = 10
lamda3(0) = 10

Matlab formatted problem
Create m file called PolyNles.m and paste the following text into it.
% S. 21* - NLE System
% Complex Chemical Equilibrium
% Verified Solution: C2H2=3.16E-10, C2H4=9.54E-8, C2H6=1.67E-7
% CH4=0.066564, CO2=0.544918, H2=5.34523, H2O=1.52165, CO=1.38852
% lamda1=24.4197, lamda2=0.253059, lamda3=1.55983, O2=5.46E-21
% Ref.:Prob. 4.5 in Problem Solving in Chemical...
function PolyNles
   xguess = [10 10 10 5.992 1 1 0.993 0.001 0.001 0.001 0.001 0.0001]; % initial guess vector
   x = fsolve(@MNLEfun, xguess);
   fprintf('The NLEs solution is:\n');
   fprintf('lamda1 = %g\n',x(1));
   fprintf('lamda2 = %g\n',x(2));
   fprintf('lamda3 = %g\n',x(3));
   fprintf('H2 = %g\n',x(4));
   fprintf('H2O = %g\n',x(5));
   fprintf('CO = %g\n',x(6));
   fprintf('CO2 = %g\n',x(7));
   fprintf('CH4 = %g\n',x(8));
   fprintf('C2H6 = %g\n',x(9));
   fprintf('C2H4 = %g\n',x(10));
   fprintf('C2H2 = %g\n',x(11));
   fprintf('O2 = %g\n',x(12));
end

function fvec = MNLEfun(IndepVarsVec)
   lamda1 = IndepVarsVec(1);
   lamda2 = IndepVarsVec(2);
   lamda3 = IndepVarsVec(3);
   H2 = IndepVarsVec(4);
   H2O = IndepVarsVec(5);
   CO = IndepVarsVec(6);
   CO2 = IndepVarsVec(7);
   CH4 = IndepVarsVec(8);
   C2H6 = IndepVarsVec(9);
   C2H4 = IndepVarsVec(10);
   C2H2 = IndepVarsVec(11);
   O2 = IndepVarsVec(12);
   R = 1.9872;
   sum = H2 + O2 + H2O + CO + CO2 + CH4 + C2H6 + C2H4 + C2H2;
   %Oxygen balance
   fvec(1,1) = 2 * CO2 + CO + 2 * O2 + H2O - 4;
   %Hydrogen balance
   fvec(2,1) = 4 * CH4 + 4 * C2H4 + 2 * C2H2 + 2 * H2 + 2 * H2O + 6 * C2H6 - 14;
   %Carbon balance
   fvec(3,1) = CH4 + 2 * C2H4 + 2 * C2H2 + CO2 + CO + 2 * C2H6 - 2;
   fvec(4,1) = log(H2 / sum) + 2 * lamda2;
   fvec(5,1) = -46.03 / R + log(H2O / sum) + lamda1 + 2 * lamda2;
   fvec(6,1) = -47.942 / R + log(CO / sum) + lamda1 + lamda3;
   fvec(7,1) = -94.61 / R + log(CO2 / sum) + 2 * lamda1 + lamda3;
   fvec(8,1) = 4.61 / R + log(CH4 / sum) + 4 * lamda2 + lamda3;
   fvec(9,1) = 26.13 / R + log(C2H6 / sum) + 6 * lamda2 + 2 * lamda3;
   fvec(10,1) = 28.249 / R + log(C2H4 / sum) + 4 * lamda2 + 2 * lamda3;
   fvec(11,1) = C2H2 - (exp(0 - (40.604 / R + 2 * lamda2 + 2 * lamda3)) * sum);
   fvec(12,1) = O2 - (exp(-2 * lamda1) * sum);
end

General Settings
Total number of equations 14
Number of implicit equations 12
Number of explicit equations 2
Elapsed time 0.13 sec
Reporting digits 8
Solution method constrained
Convergence tolerance 1E-07
Maxumum # of iterations 150
# of iterations used 11