您好,欢迎来到九壹网。
搜索
您的当前位置:首页2010-2011-2实验4 解非线性方程组实验 - 副本 (3)

2010-2011-2实验4 解非线性方程组实验 - 副本 (3)

来源:九壹网
实验4 解非线性方程组实验

成绩

专业班级 学号 姓名 报告日期 2012/4/17 .

实验类型:●验证性实验 ○综合性实验 ○设计性实验

实验目的:进一步熟练掌握解非线性方程组牛顿迭代算法,提高编程能力和解算非线性方程组问题的实践技能。

实验内容:

设有非线性方程组

x22xy0.50 22x4y40设初始值x0,y0(2.00,0.25) 误差小于0.001 实验原理

PnPn1J(Pn1)1F(Pn1)

实验说明 实验步骤

1 要求上机实验前先编写出程序代码 2 编辑录入程序

3 调试程序并记录调试过程中出现的问题及修改程序的过程 4 经反复调试后,运行程序并验证程序运行是否正确。 5 记录运行时的输入和输出。 实验总结

实验报告:根据实验情况和结果撰写并递交实验报告。 上机实验前程序代码预编写: 非线性方程的牛顿迭代法程序代码

function [P,iter,err]=newdim(F,JF,P,delta,epsilon,max1) %Input - F is the system saved as the M-file F.m

% - JF is the Jacobian of F saved as the M-file JF.m % - P is the initial approximation to the solution % - delta is the tolerance for P

% - epsilon is the tolerance for F(P)

% - max1 is the maximum number of iterations %Output - P is the approximation to the solution % - iter is the number of iterations required % - err is the error estimate for P Y=feval(F,P); for k=1:max1

J=feval(JF,P); Q=P-(J\\Y); Z=feval(F,Q); err=norm(Q-P);

relerr=err/(norm(Q)+eps); P=Q; Y=Z; iter=k;

if (err向量函数录入 function Z=F(X) x=X(1);y=X(2); Z=zeros(2,1);

Z(1)=x^2-2*x-y+0.5; Z(2)=x^2+4*y^2-4; 雅可比矩阵录入

function W=JF(X) x=X(1);y=X(2);

W=[2*x-2 -1;2*x 8*y];

初始值录入 P=[2 0.25]'; 调用函数求解

[P,iter,err]=newdim('F','JF',P,0.001,0.00001,10) P =

1.9007 0.3112

iter =

3 err =

1.5071e-005

实验总结:用牛顿法求非线性方程比较方便,收敛速度比较快,但求雅可比矩阵比较麻烦。

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 91gzw.com 版权所有 湘ICP备2023023988号-2

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务