## Solving for 4 unknowns

### Roman Plano (view profile)

on 21 Jul 2019
Latest activity Commented on by Walter Roberson

on 21 Jul 2019

### John D'Errico (view profile)

I am solving for L, V, x1, and y1, but I'm getting very large fractions that are incorrect. What should I change to have MATLAB output an actual answer for each? Thanks.
x1 and y1 are mole fractions, meaning they should be less than 1. V and L are vapor and liquid streams, which have units of mol/s. The values shouldn't be greater than 3 mol/s.
P1 = 124.13; %mmHg
P2 = 483.53; %mmHg
P = 300; %mmHg
N = 2.15; %mol/s
w = 0.5;
syms L V x1 y1
eq1 = N-L-V;
eq2 = (w*N)-(x1*L)-(y1*V);
eq3 = (x1*P1)-(y1*P);
eq4 = ((1-x1)*P1)-((1-y1)*P2);
sol = solve(eq1,eq2,eq3,eq4)
disp(sol.L)
disp(sol.V)
disp(sol.x1)
disp(sol.y1)

Walter Roberson

### Walter Roberson (view profile)

on 21 Jul 2019
Those equations with those constants do not produce values anywhere near what you indicate. Either the initial constants are wrong or else the equations are wrong
Walter Roberson

### Walter Roberson (view profile)

on 21 Jul 2019
Those values are consistent with
P1 = 143.9380911435941641229874221608
P2 = 89.673977282471909688865707721561
which is a relatively small change for P1 but a large change for P2.
If you try to make P2 fit then for consistency you need to make P = 1617.62647755732 and P1 = 776.12689120978818713663467868717, both of which are large changes.

### Tags ### John D'Errico (view profile)

on 21 Jul 2019
Edited by John D'Errico

### John D'Errico (view profile)

on 21 Jul 2019

Why do these not look like actual solutions to the equation system?
subs(eq1,{L,V,x1,y1},[1.86, 0.29, 0.537, 0.258])
ans =
0
>> subs(eq2,{L,V,x1,y1},[1.86, 0.29, 0.537, 0.258])
ans =
17/12500
>> subs(eq3,{L,V,x1,y1},[1.86, 0.29, 0.537, 0.258])
ans =
-1074219/100000
>> subs(eq4,{L,V,x1,y1},[1.86, 0.29, 0.537, 0.258])
ans =
-30130707/100000
In the last two equations, the result seems pretty significantly non-zero, not even remotely close.
So while you may think you know the solution to that system, you clearly do not.
What should you change? Well, either find what you did wrong when you wrote the equations, or recognize that the numbers you think are solutions are not that. The system is in fact, darn near linear in the unknowns. I could probably solve it by hand. (Lets see, eq3 and eq4 are linear in the unknnowns x1 and y1. So we can solve them independently for x1 and y1. Once you know x1 and y1, then eq1 and eq2 are again a linear 2x2 system of equations in the unknowns L and V. (Case closed, trivial. Pencil and paper will suffice.)
But if I let MATLAB do the job itself, then we get what is a solution. Since the problem ends up being linear in the end, the solution will be unique too, as long as the equations are not degenerate. (They appear not to be so.)
sol = solve(eq1,eq2,eq3,eq4)
sol =
struct with fields:
L: [1×1 sym]
V: [1×1 sym]
x1: [1×1 sym]
y1: [1×1 sym]
>> subs(eq1,sol)
ans =
0
>> subs(eq2,sol)
ans =
0
>> subs(eq3,sol)
ans =
0
>> subs(eq4,sol)
ans =
0
You may not like it, but there is a phrase that may apply here: garbage in, garbage out.

Roman Plano

### Roman Plano (view profile)

on 21 Jul 2019
They might not be. Those were values I found online for this problem, but they could be incorrect. Or my code is incorrect.
John D'Errico

### John D'Errico (view profile)

on 21 Jul 2019
We cannot know which it is. Something that you wrote is wrong. It may even be that what you found online is wrong. What a surprise! (LoL)
When you think you know the solution, test it, as did I. It was easy enough to verify that what you claimed to be true was in fact incorrect.
I might comment that it could be worth doing a sensitivity analysis. That is, are the constants you supply, thus the values of
P1 = 124.13; %mmHg
P2 = 483.53; %mmHg
P = 300; %mmHg
N = 2.15; %mol/s
w = 0.5;
actually exact? But if they are incorrect by some tiny amount, how would that change the found solution, which as I said, is trivial to find. My guess is this is not the issue here. It might be that you wrote the equations improperly. But I cannot guess what you did wrong.