How to solve 3 nonlinear system of equations?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I wrote a code in two files:
file: 1
function [fval,jac]= CSPW1(X)
x=X(1);
y=X(2);
z=X(3);
fval(1,1)=0.1315*x^2+0.4526*y^2+0.6793*x.*y+0.7549*z.*y-0.0378*z;
fval(2,1)=0.5983*x^2+1.5280*y^2+2.6025*x.*y+2.7582*y.*z-0.07785*z^2;
fval(3,1)=0.2335*x^3+1.0922*y^3+1.528*x.*y^2+1.6058*z.*y^2-0.07785*x.*z.^2-0.02595*z^3;
jac=[(263*x)/1000+(6793*y)/10000, (6793*x)/10000+(2263*y)/2500+(7549*z)/10000, (7549*y)/10000-189/5000;
(263*x)/1000+(6793*y)/10000, (6793*x)/10000+(2263*y)/2500+(7549*z)/10000, (7549*y)/10000-189/5000;
(263*x)/1000+(6793*y)/10000, (6793*x)/10000+(2263*y)/2500+(7549*z)/10000, (7549*y)/10000-189/5000];
File: 2
X0=[10; 10; 30];
maxIter=5;
tolX=1e-12;
X=X0;
Xold=X0;
for i=1:maxIter
[f,j]=CSPW1(X);
X=X-inv(j)*f;
err(:,i)=abs(X-Xold);
Xold=X;
if (err(:,i)<tolX)
break;
end
end
But in answer it shows "Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN."
How to solve then?
0 Kommentare
Antworten (1)
madhan ravi
am 2 Jan. 2019
5 Kommentare
Walter Roberson
am 2 Jan. 2019
Actual solution:
x = 3.4691311028950902695051613877565 y = -0.22793089975528930231491570459169 z = 5.0935669467576127190815147121607
This is one of the 7 solutions -- in particular the one that is smallest Euclidean distance to your starting point of [10 10 30] . The second closest solution is [0 0 0]
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!