作业帮 > 数学 > 作业

用牛顿迭代法解非线性方程组

来源:学生作业帮 编辑:作业帮 分类:数学作业 时间:2024/11/08 12:18:47
用牛顿迭代法解非线性方程组
有两个非线性方程,未知数是x1,x2:
(15x1+10x2)/[(40-30x1-10x2)^2×(15-15x1)]=5e-4;
(15x1+10x2)/[(40-30x1-10x2)×(10-10x2)]=4e-2.
大侠们帮帮忙,实在整不出来
function [r,n]=mulNewton(x0,eps)
if nargin==1
eps=1.0e-4;
end
r=x0-myf(x0)*inv(dmyf(x0));
n=1;
tol=1;
while tol>eps
x0=r;
r=x0-myf(x0)*inv(dmyf(x0));
tol=norm(r-x0);
n=n+1;
if(n>100000)
disp('迭代步数太多,方程可能不收');
return;
end
end
function f=myf(x)
x1=x(1);
x2=x(2);
f1=(15*x1+10*x2)-((40-30*x1-10*x2)^2*(15-15*x1))*5e-4;
f2=(15*x1+10*x2)-((40-30*x1-10*x2)*(10-10*x2))*4e-2;
f=[f1 f2];
function df=dmyf(x)
x1=x(1);
x2=x(2);
df=[ (3*(27*x1^2 + 12*x1*x2 - 66*x1 + x2^2 - 14*x2 + 60))/4,...
(3*x1*x2 - 3*x2 - 21*x1 + 9*x1^2 + 32)/2;(-3)*(4*x2 - 9),(-2)*(6*x1 + 4*x2 - 15)]
----------------------------------------------------------------------------------------------------------
[r,n]=mulNewton([0.2 0.6],0.001)
df =
30.9600 13.3600
19.8000 22.8000
df =
33.1741 13.7408
22.0443 24.5260
df =
35.4490 14.2583
21.4349 24.9400
df =
35.2223 14.2212
21.1843 24.7600
df =
34.9859 14.1678
21.2334 24.7120
df =
34.9828 14.1660
21.2601 24.7231
r =
0.1203 0.4785
n =
6