Info

This question is closed. Reopen it to edit or answer.

Problem solving system of nonlinear equations

1 view (last 30 days)
Miguel Fernandes
Miguel Fernandes on 2 Dec 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
Hello
I was writing a script where I have 3 equations that I multiply by a constant and that I have to derivate.
After that I add another equation and try to solve that system of four equations to get the result I need, but the answer it gives out doesnt match the real answer (that my teacher gave me)... Here is my script:
syms P1 P2 P3 lambda
I1=510+7.2*P1+0.00142*P1^2;
I2=130+7.85*P2+0.00194*P2^2;
I3=78.0+7.97*P3+0.00482*P3^2;
fc1=1.1;
fc2=1.0;
fc3=1.0;
F1=I1*fc1;
F2=I2*fc2;
F3=I3*fc3;
F1=diff(F1);
F2=diff(F2);
F3=diff(F3);
After I got these three results, based on a tutorial I saw, I did a function:
function F = root2d(x)
F(1) = (71*x(1)^2)/50000 + (36*x(1))/5 - x(4) + 510;
F(2) = (97*x(2)^2)/50000 + (157*x(2))/20 - x(4) + 130;
F(3) = (241*x(3)^2)/50000 + (797*x(3))/100 - x(4) + 78;
F(4)= x(1) + x(2) + x(3) - 850;
end
Finnally I wrote these three lines:
fun = @root2d;
x0 = [0,0,0,0];
x = fsolve(fun,x0)
Unfortunatly the answer it gives out is:
x =
1.0e+03 *
0.2789 0.2966 0.2745 2.6288
I know that the final equations are:
(71*P1^2)/50000 + (36*P1)/5 + 510 = lambda
(97*P2^2)/50000 + (157*P2)/20 + 130 = lambda
(241*P3^2)/50000 + (797*P3)/100 + 78 = lambda
P1 + P2 + P3 = 850
And the real answer is: P1=704.6 P2=111.8 P3=32.6 P4=8.284
What did I do wrong? Is there a better way of doing this?

Answers (1)

Walter Roberson
Walter Roberson on 3 Dec 2015
There are multiple solutions to those equations, but all the solutions to the equations you give are imaginary.
The values you give as the "real answer" do not work in the equations: if you substitute in those values you give the contradictions [6288.094847 = 8.284, 1031.878526 = 8.284, 342.9445032 = 8.284, 849.0 = 850] and are therefore not solutions.

Community Treasure Hunt

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

Start Hunting!