python牛顿法解非线性方程组_牛顿法解非线性方程组的MATLAB程序

展开全部

Newton's method is the classic algorithm for finding roots of functions. The breif introduction is written below.

resize,m_lfit,w_600,h_800,limit_1

The analytic solution is

resize,m_lfit,w_600,h_800,limit_1

The code isclear all

x = zeros(1,2);

f = zeros(1,2);

tol = 1E-7;

invJ = zeros(2,2);

x(1) = 0.23;

x(2) = 0.69;

for n = 1:1:1E4

f(1) = x(1)+85.4/x(2)-1;

f(2) = x(1)-10/x(2);

invJ(1,1) = 10/95.4;

invJ(1,2) = 85.4/95.4;

invJ(2,1) = -x(2)^2/95.4;

invJ(2,2) = x(2)^2/95.4;

xn = x'-invJ*f';

if (abs(x(1)-xn(1))/abs(xn(1)) < tol ...

&& abs(x(2)-xn(2))/abs(xn(2)) < tol)

fprintf('The maximum number of iterations is %d\n', n)

disp('The solution within tolerance 1E-7 is')

disp(xn')

return;

end

x = xn';

end

disp('The solution did not converge to x-axis')

The generated result is

resize,m_lfit,w_600,h_800,limit_1


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部