二等分法(数值分析) [英] Bisection method (Numerical analysis)

查看:444
本文介绍了二等分法(数值分析)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在找到每个根之前要进行多少次递归?还有,那些是根?

How many recursions are made before every single root is found? Also, which ones are the roots?


这是我的代码:


Here's my code:

e=0.000001; 
f1=@(x) 14.*x.*exp(x-2)-12.*exp(x-2)-7.*x.^3+20.*x.^2-26.*x+12;

a=0; 
c=3; 
while abs(c-a)>e 
    b=(c+a)/2; 
    if f1(a)*f1(b)<0 
        c=b; 
    else
        a=b;
    end    
    disp(b);  
end

推荐答案

二分法通过获取某个初始间隔[a,b]的端点并找出间隔的哪一半必须包含根来进行工作(它评估中点,并确定哪一半具有符号更改).然后二等分在确定的一半上重复该过程.

Bisection works by taking endpoints of some initial interval [a,b] and finding which half of the interval must contain the root (it evaluates the midpoint, and identifies which half has the sign change). Then bisection repeats the process on the identified half.

对分仅收敛于一个可能的根,如果函数在[a,b]内部具有多个根,则通常很难预测它将收敛至哪个特定根. (注意:由于二等分是完全确定性的算法,如果您给它相同的初始间隔,它将始终会收敛到完全相同的根.)迭代只是对找到的根进行近似精炼,它们找不到多个根.

Bisection converges upon only one possible root, and if your function has multiple roots inside [a,b], it is difficult to predict in general which specific root it will converge to. (Note: since bisection is a fully deterministic algorithm, it will always converge to the exact same root if you give it the same initial interval.) The iterations simply refine your approximation of found root, they do not find multiple roots.

要直接回答您的问题,二等分不会[0,3]中发现函数的所有三个根.它只会找到一个根,这由二等分代码的最终迭代来标识.二等分迭代所输出的所有值都简单地显示了算法朝着其最终找到的根所取得的进展(这些值应该是收敛于最终值的序列).

To directly answer your question, bisection will not discover all three of the roots of your function inside [0,3]. It will find just one root, and this is identified by the final iteration of your bisection code. All of the values outputted by the bisection iterations simply show the progress made by the algorithm towards the one root it eventually found (and these values should be a sequence converging upon the final value).

这篇关于二等分法(数值分析)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆