- 9
- 0
- 约2.19千字
- 约 5页
- 2016-11-26 发布于重庆
- 举报
5matlab牛顿法求解非线性方程组的数值解问题
P184牛顿法求解非线性方程组的数值解问题:——5
牛顿法只可以求解方程个数和未知数个数相等的非线性方程组;;;
程序:注意x x1 x2的形式:
程序一(NewtonS.m)
function s=NewtonS(x,eps)
if nargin==1
eps=1e-6;
else if nargin1
error(please input two shu);
return;
end
end
n=1; a=[0];
x1=NewtonSfun1(x); a=[n,x,x1];
x2=-NewtonSdfFun(x); x3=inv(x2); x0=x1*x3;
while norm(x0)=eps
x=x0+x;
x1=NewtonSfun1(x); n=n+1; a=[a;n,x,x1];
x2=-NewtonSdfFun(x); x3=inv(x2); x0=x1*x3;
end
a
程序2 M文件(NewtonSfun1 .m)求解方程组的函数值:
function y=NewtonSfun1(x)
y(1)=x(1)*x(1)-10*x(1)+x(2)*x(2)+8;
y(2)=x(1)*x(2)*x(2)+x(1)-10*x(2)+8;
y=[y(1),
原创力文档

文档评论(0)