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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值