Asked by Roman Plano
on 21 Jul 2019

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)

Answer by John D'Errico
on 21 Jul 2019

Edited by John D'Errico
on 21 Jul 2019

Accepted Answer

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
on 21 Jul 2019

John D'Errico
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.

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## Walter Roberson (view profile)

## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/472710-solving-for-4-unknowns#comment_726781

## Walter Roberson (view profile)

## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/472710-solving-for-4-unknowns#comment_726802

Sign in to comment.