Solving nonlinear system of equations with different variables
6 views (last 30 days)
Show older comments
Claudio Hediger
on 30 Dec 2018
Commented: Claudio Hediger
on 30 Dec 2018
Hello
I would like to solve a nonlinear system of equations. Im new to matlab and therefore i dont have enough experience to get this problem solved by myself.
i have googled around a bit but unfortunately didnt got the hint that i needed. Therefore i write now here in this community.
I hope someone can help me.
Here is my problem:
function F = root2d(x)
F(1) = (R1*(C2+C3) + R2*(C1+C2) + R3*C3*(1-1 / ( R5 / (R4+R5))))-0.24792;
F(2) = (R1*R2*(C1*C2 + C1*C3 +C2*C3)+R1*R3*C2*C3 +R2*R3*(C1+C2)*C3*(1-1 / ( R5 / (R4+R5)) ))-0.7807;
F(3) = (R1*C1*R2*C2*R3*C3)-0.0948;
F(4) = ((R1*C1*R2*C2*R3*C3)/ ( R5 / (R4+R5)) )-0.948;
end
I would like to find solutions for
R1, R2, R3, C1, C2, C3
R4 and R5 are known. R4 is 1 and R5 is 9.
How do i have to solve this system?
I have tried it that way:
fun = @root2d;
x0 = [1,1,1,1];
x = fsolve(fun,x0)
function F = root2d(x)
F(1) = (R1*(C2+C3) + R2*(C1+C2) + R3*C3*(1-1 / ( R5 / (R4+R5))))-0.24792;
F(2) = (R1*R2*(C1*C2 + C1*C3 +C2*C3)+R1*R3*C2*C3 +R2*R3*(C1+C2)*C3*(1-1 / ( R5 / (R4+R5)) ))-0.7807;
F(3) = (R1*C1*R2*C2*R3*C3)-0.0948;
F(4) = ((R1*C1*R2*C2*R3*C3)/ ( R5 / (R4+R5)) )-0.948;
end
but it tells me that it was not able to find any solutions.
Thanks in advance.
Regards
0 Comments
Accepted Answer
Walter Roberson
on 30 Dec 2018
You have 4 equations that you want to solve for 6 variables. There will either be no solutions or an infinite number of solutions.
In your case, there are no solutions.
If you solve the first three equations for R1, R2, R3, you can do that by expressing R2 as the roots of a degree 6 polynomial, and then expressing R1 and R3 in terms of that; for example,
R1 = (4740 - 50000*C1^3*R2^3 + (-100000*C2*R2^3 + 12396*R2^2)*C1^2 + (-50000*C2^2*R2^3 + 12396*C2*R2^2 - 39035*R2)*C1)*`/`(50000*C1*C2^2*R2^2)
However, when you then substitute the R1, R2, R3 solutions into the fourth equation, you get out -316/375 instead of an equation in multiple variables. Your equations are rank deficient and inconsistent.
6 Comments
madhan ravi
on 30 Dec 2018
I deleted my answer because it was clearly stated that No solution found which by the way I didn’t notice clearly at the moment until sir Walter stated it.
More Answers (2)
John D'Errico
on 30 Dec 2018
Edited: John D'Errico
on 30 Dec 2018
Claudio, no, I'm sorry, but you do not have the answer. Lets look at your equations.
syms R1 R2 R3 C1 C2 C3
R4 = 9;
R5 = 1;
F(1) = (R1*(C2+C3) + R2*(C1+C2) + R3*C3*(1-1 / ( R5 / (R4+R5))))-0.24792;
F(2) = (R1*R2*(C1*C2 + C1*C3 +C2*C3)+R1*R3*C2*C3 +R2*R3*(C1+C2)*C3*(1-1 / ( R5 / (R4+R5)) ))-0.7807;
F(3) = (R1*C1*R2*C2*R3*C3)-0.0948;
F(4) = ((R1*C1*R2*C2*R3*C3)/ ( R5 / (R4+R5)) )-0.948;
pretty(F(3))
237
C1 C2 C3 R1 R2 R3 - ----
2500
>> pretty(F(4))
237
10 C1 C2 C3 R1 R2 R3 - ---
250
Do you notice anything strange about the last two equations? Ie., that they are identical?
F(3) tells us that the product of all 6 unknowns is 237/2500.
F(4) tells us that the product of all 6 unknowns, when multiplied by 10, is 237/250. Is that any surprise?
I suppose you could create a few more equations, multiplying them by any constant factor you wish. It would still be the very same equation. NO different.
So you have only 3 distinct equations. We can ignore the 4th completely. You have 6 unknowns. You can pick 3 of them to arbitrarily set to any fixed constants. Now, can we solve for three of those unknowns, in terms of the others? We can try, but we will hit a dead end of some sorts.
R123 = solve(F(1:3),[R1,R2,R3])
R123 =
struct with fields:
R1: [6×1 sym]
R2: [6×1 sym]
R3: [6×1 sym]
R123.R1
ans =
***(lengthy symbolic crap, involving calls to rootof, so I am not showing it here) ***
As you see, MATLAB cannot solve the problem, because it is eqivalent to solving a 6th degree polynomial equation, with general coefficients. We know that to be unsolvable since the times of Abel-Ruffini.
If we set the values of C1, C2, C3, to be any numbers, then we can find solutions.
vpa(subs(R123.R1,[C1, C2, C3],[1 2 3]))
ans =
0.3316004237603664602689770159054 - 0.48968928642149717589266980263974i
0.3316004237603664602689770159054 + 0.48968928642149717589266980263974i
-0.67727571082108932181365367776708
- 0.44545496553550952707026021441356 - 0.3736322321293556146757255743177i
- 0.44545496553550952707026021441356 + 0.3736322321293556146757255743177i
1.0041527943713754554162200747834
vpa(subs(R123.R2,[C1, C2, C3],[1 2 3]))
ans =
- 0.079845331250055433847244132307056 + 0.43155633804501187058826539850356i
- 0.079845331250055433847244132307056 - 0.43155633804501187058826539850356i
0.20956799173702439009045715632746
0.015440948938726560130578944933645 - 0.21001674375391901343813988516564i
0.015440948938726560130578944933645 + 0.21001674375391901343813988516564i
0.084520772885633357342873218419357
vpa(subs(R123.R3,[C1, C2, C3],[1 2 3]))
ans =
0.043353560187098740733450099355771 - 0.042732496961942602507353808062521i
0.043353560187098740733450099355771 + 0.042732496961942602507353808062521i
-0.11131831773682864588136655258715
- 0.089958221513383998331835712491365 - 0.092526347848464263470112871373533i
- 0.089958221513383998331835712491365 + 0.092526347848464263470112871373533i
0.18616319594495471663369333441389
Pick any values for C1, C2, C3, and all 6 numerical solutions will drop out.
But trying to use fsolve to solve the problem will find one solution, one that completely depends on your starting values. Pick a different start point, and you will get a different solution.
Claudio Hediger
on 30 Dec 2018
1 Comment
John D'Errico
on 30 Dec 2018
Edited: John D'Errico
on 30 Dec 2018
What you don't realize is that your "solution" finds only one of infinitely many solutions.
You can pick any two of those vairables, and set them equal to essentially any value you wish. Then you will be able to solve for the other 4 variables.
So this is not in fact a solution.
Worse, as Walter points out, your equations are rank deficiient. So you really need to pick THREE of the unknowns to fix at chosen values.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!