Solving system of 8 non-linear equations

조회 수: 10 (최근 30일)
Petar Krizan
Petar Krizan 2021년 3월 17일
댓글: John D'Errico 2021년 3월 17일
How to solve this system of 8 equations:
  댓글 수: 2
John D'Errico
John D'Errico 2021년 3월 17일
Let me repeat: Why in the name of god and little green apples would you paste in a PICTURE of text, when you could have more easily pasted in the text? That makes it impossible for me to copy your text and use it in MATLAB! Why would you want to make it more difficult for someone to help you????
Petar Krizan
Petar Krizan 2021년 3월 17일
I apologize for posting picture.
eqn1 = x1 == 0.25*x2;
eqn2 = x3 == (130*x7 + 0.5)*((x1^2)/19.62);
eqn3 = x4 == 0.001963495*x2;
eqn4 = x3 == 87794*x1;
eqn5 = x6 == 43897*x2;
eqn6 = x7 == (-1.8*log(6.9/x5))^(-2);
eqn7 = x8 == (-1.8*log(6.9/x6))^(-2);
eqn8 = x3 == 18 - ((x2)^2)/19.62;

댓글을 달려면 로그인하십시오.

답변 (1개)

John D'Errico
John D'Errico 2021년 3월 17일
편집: John D'Errico 2021년 3월 17일
This is a nonlinear homogeneous problem, in the sense that the all zero solution "works". See that if x5==x6==0, then the logs give us inf, then 1/inf-->0.
But suppose some non-trivial solution exists? I see that x8 appears in only one equation. So imagine we choose some value for x8. That gives us x6 directly. Which gives us in a chain x2 --> x1--> x3 --> x7 --> x5. And we get x4 from x2.
So just pick ANY non-zero value you desire for x8. The rest fall out. Pencil and paper will suffice. Do you really need MATLAB?
Now that you have posted code...
syms x1 x2 x3 x4 x5 x6 x7 x8 positive
eqn1 = x1 == 0.25*x2;
eqn2 = x3 == (130*x7 + 0.5)*((x1^2)/19.62);
eqn3 = x4 == 0.001963495*x2;
eqn4 = x3 == 87794*x1;
eqn5 = x6 == 43897*x2;
eqn6 = x7 == (-1.8*log(6.9/x5))^(-2);
eqn7 = x8 == (-1.8*log(6.9/x6))^(-2);
eqn8 = x3 == 18 - ((x2)^2)/19.62;
It seems to make little sense for any of these variables to be negative. And zero gets us in a bad place too. So I added positivity as an assumption for these variables.
We can do as I suggested. I'll start it by hand so you can see how it would work.
x6sol = solve(eqn7,x6)
x6sol = 
And there, we see two solutions. If I look more carefully at what it said, it would clearly depend on the branch we take in a square root involving x8. Should we take the positive or negative branch there?
Sicne we will have other branches in the solution for x5, it looks like there may be as many as 4 non-trivial solutions.
x2sol = solve(eqn5,x2)
x2sol = 
And since we already have x6, we just tumble down the chain. That gives us x4 and x1. Now we get x3. Now we get x7. And finally, we get x5.
Can I just get MATLAB to do all the work for me, as a function of the unknown value for x8? We can do that by recognizing we need these equations:
eqn7 --> x6
eqn5 --> x2
eqn3 --> x4
eqn1 --> x1
eqn4 --> x3
eqn2 --> x7
eqn6 --> x5
And that leaves eqn8 out, since we need it for nothing. So we can try this:
sol = solve(eqn1,eqn2,eqn3,eqn4,eqn5,eqn6,eqn7,[x1,x2,x3,x4,x5,x6,x7],'returnconditions',true)
sol = struct with fields:
x1: [4×1 sym] x2: [4×1 sym] x3: [4×1 sym] x4: [4×1 sym] x5: [4×1 sym] x6: [4×1 sym] x7: [4×1 sym] parameters: [1×0 sym] conditions: [4×1 sym]
sol.conditions
ans = 
sol.x1
ans = 
sol.x2
ans = 
Etc. So we see 4 solutions. And that ignores eqn8. Do any of these solutions also solve eqn8?
x8eqn = sol.x3 - (18 - ((sol.x2).^2)/19.62)
x8eqn = 
Remember, a non-trivial solution allows ANY non-negative value for x8. So all we need do now is chose the value of x8 that satisfies either sigma1==0 or sigma2==0. And that will imply the solution for the remainder of the variables.
x8_1 = solve(x8eqn(1),x8)
x8_1 = 
x8_2 = solve(x8eqn(3),x8)
x8_2 = Empty sym: 0-by-1
So the sigma1 solution yields an empty result, and thus a unique solution for x8.
vpa(x8_1)
ans = 
0.11309312511905908373224842841866
We can now stuff that back into the solution in sol to get the remainder of the unknowns.
Could I have just tried solve on the entire set of equations? Possibly, but a directed solution that uses intelligence is far better than trying to get the computer to do all of the thinking for you. Odds are it would have yielded a complex mess that would not have made the solution as obvious as it is here.
  댓글 수: 2
Petar Krizan
Petar Krizan 2021년 3월 17일
This is a physical problem. If I assume that x5 = x6 = 0, I get the wrong numbers. The same goes for x8.
John D'Errico
John D'Errico 2021년 3월 17일
That you get a solution you do not like for the trivial solution does not mean it does not solve the equations posed.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by