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

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

问题描述

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

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天全站免登陆