声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2808|回复: 2

[经典算法] 求牛顿-拉夫逊法matlab代码?

[复制链接]
发表于 2007-11-15 16:37 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
求牛顿-拉夫逊法matlab代码?
谢谢!
回复
分享到:

使用道具 举报

发表于 2007-12-2 10:46 | 显示全部楼层
  1. function [P,iter,err]=newdim(F,JF,P,delta,epsilon,max1)
  2. %Input   -F is the system saved as the M-file F.m
  3. %        -JF is the Jacobian of F saved as the M-file JF.m
  4. %        -P is the initial approximation to the solution
  5. %        -delta is the tolerance for P
  6. %        -epsilon is the tolerance for F(P)
  7. %        -max1 is the maximum number of iterations
  8. % Output -P is the approximation to the solution
  9. %        -iter is the number of iterations required
  10. %        -err is the error estimate of P
  11. Y=feval(F,P);
  12. for k=1:max1
  13.     J=feval(JF,P);
  14.     Q=P-(J\Y')';
  15.     Z=feval(F,Q);
  16.     err=norm(Q-P);
  17.     relerr=err/(norm(Q)+eps);
  18.     P=Q;
  19.     Y=Z;
  20.     iter=k;
  21.     if (err<delta)|(relerr<delta)|(abs(Y)<epsilon)
  22.         break;
  23.     end
  24. end
复制代码
发表于 2013-5-11 10:50 | 显示全部楼层
好东西~学习了~
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-20 15:01 , Processed in 0.064482 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表