数值分析学习(二)之Open Methods求根
2015-01-14 17:11
976 查看
求根的方法有很多,前面介绍了用交叉法(Bracketing Method)求函数的根,本文介绍几种用开型法(Open Methods)求根的方法。但着重介绍牛顿-拉普森(Newton-Raphson)法。在Bracketing Methods中,一般需要两个初始的猜想值,用于迭代的起始。但是在Open Methods中,只需要一个起始值或者两个但是不需要让它们分布在精确值对的两侧。但是Open
Methods方法的缺点是,在有些情况下他不能得到收敛的值,如下图:
1、牛顿-拉普森(Newton-Raphson)方法
牛顿-拉普森迭代算法的推导,如图:
斜率slope能通过如下方程得到:
其中,xi为开始的假设值。则下一个x值的求取形式如下:
这就是牛顿-拉普森迭代公式。
举个例子:
,初始猜想值x = 0.5,则求根迭代公式为
。通过excel,可以得到求根迭代过程结果如下:
虽然第一次预测得到很不好的结果,但是最后还是得到了正确的值。只是迭代过程变得很慢。牛顿-拉普森对存在多个根和下图几种情况应用的时候,收敛性很不好。
下面贴上代码:
除此之外,还有几种重要的Open Methods求根方法:
2、Secant Method 和 Modified Secant Method
3、Brent's Method(结合了Inverse Quadratic Interpolation 和 Secant Method)
4、多项式逼近
(具体介绍详见参考书籍第六章)
参考书籍: Applied Numerical Methods with Matlab for Engineers and Scientists_3ed
Methods方法的缺点是,在有些情况下他不能得到收敛的值,如下图:
1、牛顿-拉普森(Newton-Raphson)方法
牛顿-拉普森迭代算法的推导,如图:
斜率slope能通过如下方程得到:
其中,xi为开始的假设值。则下一个x值的求取形式如下:
这就是牛顿-拉普森迭代公式。
举个例子:
,初始猜想值x = 0.5,则求根迭代公式为
。通过excel,可以得到求根迭代过程结果如下:
虽然第一次预测得到很不好的结果,但是最后还是得到了正确的值。只是迭代过程变得很慢。牛顿-拉普森对存在多个根和下图几种情况应用的时候,收敛性很不好。
下面贴上代码:
function [root , ea, iter] = newtraph(func, dfunc, xr, es, maxit, varargin) % newtraph: Newton-Raphson root location zeroes % [root,ea,iter]=newtraph(func,dfunc,xr,es,maxit,p1,p2,...): % uses Newton-Raphson method to find the root of func % input: % func = name of function % dfunc = name of derivative of function % xr = initial guess % es = desired relative error (default = 0.0001%) % maxit = maximum allowable iterations (default = 50) % p1,p2,... = additional parameters used by function % output: % root = real root % ea = approximate relative error (%) % iter = number of iterations if nargin < 3 error('At least 3 input argument required'); end if nargin < 4 | isempty(es) es = 0.0001; end if nargin < 5 | isempty(maxit) maxit = 50; end iter = 0; while(1) xrold = xr; xr = xr - func(xr)/dfunc(xr); iter = iter + 1; if xr ~= 0 ea = abs((xr - xrold)/xr) * 100; end if ea <= es | iter >= maxit break; end end root = xr;
除此之外,还有几种重要的Open Methods求根方法:
2、Secant Method 和 Modified Secant Method
3、Brent's Method(结合了Inverse Quadratic Interpolation 和 Secant Method)
4、多项式逼近
(具体介绍详见参考书籍第六章)
参考书籍: Applied Numerical Methods with Matlab for Engineers and Scientists_3ed
相关文章推荐
- 数值分析学习(一)之交叉法(Bracketing Methods)求根
- 数值分析内容概览及学习总结
- 数值分析小白学习之路(二) 插值法
- MFC OnFileNew OnFileOpen过程分析代码(以记录MFC学习点滴)
- 《用Python学习数值分析--最小二乘》
- 《用Python学习数值分析--插值与拟合》
- IBM openblockchain学习(三)--Ledger源码分析
- 学习数值分析
- ffmpeg学习五:avformat_open_input函数源码分析(以mp4文件为例)
- 《用Python学习数值分析-- 最优化》
- 数值分析 ---学习和了解科学计算的桥梁
- 嵌入式学习-驱动开发-lesson6.2-UART驱动初始化和open流程分析
- 【学习笔记之Openlayers3】路径分析篇(第六篇)
- 统计分析学习之数值分析方法
- 《用Python学习数值分析--解方程组》
- 计算数学与数值分析(数值计算方法)——学习资料(更新...........)
- 统计分析学习之数值分析方法
- LIVE555再学习 -- OpenRTSP 源码分析
- Lucene 学习之二:数值类型的索引和范围查询分析