Newton Jacobi Nonlinear System
Show older comments
clear;
x(1)=2;
y(1)=1;
z(1)=2;
for k=1:100
F(1,1)= x(k)^2* y(k)+x(1)^0.5*y(1)^2-z(k);
F(2,1)= exp(x(k))-z(k)^2-sin(y(1));
F(3,1)= x(k)*y(k)*z(k)-x(k)-y(k)-z(k);
J(1,1:3)= [2*x(k)*y(k)-1/(2*x(k)^0.5), x(k)^2+2*x(k)^0.5*y(k), -1];
J(2,1:3)= [exp(x(k)), -cos(y(k)), -2*z(k)];
J(3,1:3)= [y(k)*z(k)-1, x(k)*z(k)-1, x(k)*y(k)-1];
X= [x(k);y(k);z(k)];
Xnew= X-J^-1*F;
x(k+1)=Xnew(1);
y(k+1)=Xnew(2);
z(k+1)=Xnew(3);
xerr= abs(x(k+1)-x(k));
yerr= abs(y(k+1)-y(k));
zerr= abs(z(k+1)-z(k));
e(k+1)= max(xerr,yerr,zerr);
if e(k+1)<0.0001
break; end
end
[x' y' z' e']
Error using max
Dimension argument is not supported when two input arrays are provided.
Accepted Answer
More Answers (0)
Categories
Find more on Verification, Validation, and Test in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!