POLYMATH Report          NLE 
 Nonlinear Equations 2016-May-31 

Calculated values of NLE variables
    Variable Value f(x) Initial Guess Initial f(x)
1 beta1 0.732999 -1.1E-16 0.8 0.0E00
2 t 88.5378 2.3E-13 100 -4.8E-03
3 x11 0.022698 -2.8E-15 0 -1.8E-02
4 x12 0.686748 4.4E-13 1 1.0E00
5 x21 0.977302 3.0E-15 1 4.8E-02
6 x22 0.313252 -2.3E-15 0 -2.0E-01

    Variable Value Initial Value
1 A 1.7 1.7
2 B 0.7 0.7
3 gamma11 33.3665 50.1187
4 gamma12 1.10282 1
5 gamma21 1.00461 1
6 gamma22 3.13422 5.01187
7 k11 15.6757 37.2819
8 k12 0.518108 0.743872
9 k21 0.659152 1.00482
10 k22 2.05646 5.03605
11 p1 357.05 565.343
12 p2 498.659 763.666
13 y1 0.35581 0
14 y2 0.64419 1.00482

Nonlinear equations
1 f(x11) = x11-0.2/(beta1+(1-beta1)*k11/k12) = 0
2 f(x21) = x21-0.8/(beta1+(1-beta1)*k21/k22) = 0
3 f(x12) = x12-x11*k11/k12 = 0
4 f(x22) = x22-x21*k21/k22 = 0
5 f(t) = x11*(1-k11)+x21*(1-k21) = 0
6 f(beta1) = (x11-x12)+(x21-x22) = 0

Explicit equations
1 p1 = 10^(7.62231-1417.9/(191.15+t))
2 p2 = 10^(8.10765-1750.29/(235+t))
3 A = 1.7
4 B = 0.7
5 gamma11 = 10^(A*x21*x21/((A*x11/B+x21)^2))
6 gamma21 = 10^(B*x11*x11/((x11+B*x21/A)^2))
7 gamma12 = 10^(A*x22*x22/((A*x12/B+x22)^2))
8 gamma22 = 10^(B*x12*x12/((x12+B*x22/A)^2))
9 k11 = gamma11*p1/760
10 k21 = gamma21*p2/760
11 k12 = gamma12*p1/760
12 k22 = gamma22*p2/760
13 y1 = k11*x11
14 y2 = k21*x21

Problem source text
# S. 18* - NLE System
# Three Phase Equilib.
# Verified solution: x11 = 0.0226982, x12 = 0.6867476
# x21 = 0.9773018, x22 = 0.3132524, t = 88.5378, beta1 = 0.732999
#Ref.:Prob. 12.2 in Problem Solving in Chemical...
f(x11) = x11-0.2/(beta1+(1-beta1)*k11/k12)
f(x21) = x21-0.8/(beta1+(1-beta1)*k21/k22)
f(x12) = x12-x11*k11/k12
f(x22) = x22-x21*k21/k22
f(t) = x11*(1-k11)+x21*(1-k21)
f(beta1) = (x11-x12)+(x21-x22)
p1 = 10^(7.62231-1417.9/(191.15+t))
p2 = 10^(8.10765-1750.29/(235+t))
A = 1.7
B = 0.7
gamma11 = 10^(A*x21*x21/((A*x11/B+x21)^2))
gamma21 = 10^(B*x11*x11/((x11+B*x21/A)^2))
gamma12 = 10^(A*x22*x22/((A*x12/B+x22)^2))
gamma22 = 10^(B*x12*x12/((x12+B*x22/A)^2))
k11 = gamma11*p1/760
k21 = gamma21*p2/760
k12 = gamma12*p1/760
k22 = gamma22*p2/760
y1 = k11*x11
y2 = k21*x21
x11(0)=0
x21(0)=1
x12(0)=1
x22(0)=0
t(0)=100
beta1(0)=0.8

Matlab formatted problem
Create m file called PolyNles.m and paste the following text into it.
% S. 18* - NLE System
% Three Phase Equilib.
% Verified solution: x11 = 0.0226982, x12 = 0.6867476
% x21 = 0.9773018, x22 = 0.3132524, t = 88.5378, beta1 = 0.732999
% Ref.:Prob. 12.2 in Problem Solving in Chemical...
function PolyNles
   xguess = [0 1 1 0 100 0.8]; % initial guess vector
   x = fsolve(@MNLEfun, xguess);
   fprintf('The NLEs solution is:\n');
   fprintf('x11 = %g\n',x(1));
   fprintf('x21 = %g\n',x(2));
   fprintf('x12 = %g\n',x(3));
   fprintf('x22 = %g\n',x(4));
   fprintf('t = %g\n',x(5));
   fprintf('beta1 = %g\n',x(6));
end

function fvec = MNLEfun(IndepVarsVec)
   x11 = IndepVarsVec(1);
   x21 = IndepVarsVec(2);
   x12 = IndepVarsVec(3);
   x22 = IndepVarsVec(4);
   t = IndepVarsVec(5);
   beta1 = IndepVarsVec(6);
   p1 = 10 ^ (7.62231 - (1417.9 / (191.15 + t)));
   p2 = 10 ^ (8.10765 - (1750.29 / (235 + t)));
   A = 1.7;
   B = 0.7;
   gamma11 = 10 ^ (A * x21 * x21 / ((A * x11 / B + x21) ^ 2));
   gamma21 = 10 ^ (B * x11 * x11 / ((x11 + B * x21 / A) ^ 2));
   gamma12 = 10 ^ (A * x22 * x22 / ((A * x12 / B + x22) ^ 2));
   gamma22 = 10 ^ (B * x12 * x12 / ((x12 + B * x22 / A) ^ 2));
   k11 = gamma11 * p1 / 760;
   k21 = gamma21 * p2 / 760;
   k12 = gamma12 * p1 / 760;
   k22 = gamma22 * p2 / 760;
   y1 = k11 * x11;
   y2 = k21 * x21;
   fvec(1,1) = x11 - (0.2 / (beta1 + (1 - beta1) * k11 / k12));
   fvec(2,1) = x21 - (0.8 / (beta1 + (1 - beta1) * k21 / k22));
   fvec(3,1) = x12 - (x11 * k11 / k12);
   fvec(4,1) = x22 - (x21 * k21 / k22);
   fvec(5,1) = x11 * (1 - k11) + x21 * (1 - k21);
   fvec(6,1) = x11 - x12 + x21 - x22;
end

General Settings
Total number of equations 20
Number of implicit equations 6
Number of explicit equations 14
Elapsed time 0.02 sec
Reporting digits 8
Solution method safenewt
Max iterations 150
Tolerance F 1E-07
Tolerance X 1E-07
Tolerance min 1E-07