SmtC: Show me the Code
Ole Peter Smith
Instituto de Matemática e Estatística
Universidade Federal de Goiás
http://www.olesmith.com.br

Bisecção
Quando Pedro me fala sobre Paulo
Sei mais do Pedro do que do Paulo
Sigmund Freud
< Isolamento | Implementação | Definir Funções >

Implementação: Bisecção

Python Listing: ../Bisection.py.
from Isolate import Isolate_Root

def Bisection(f,a,b,eps=1.0E-6):
    #List of x-values
    xs=[]
    
    a,b=Isolate_Root(f,a,b)

    if (not a and not b):
        return xs
    
    fa=f(a)
    fb=f(b)
    
    
    stop=False
    while (not stop):
        x=0.5*(a+b)
        fx=f(x)
    
        if (fa*fx<0.0):
            b=x
            fb=fx
        else:
            a=x
            fa=fx
            
        #Add to sequence
        xs.append(x)
        
        if (abs(fx)<eps): stop=True

    return xs
< Isolamento | Implementação | Definir Funções >
Messages:
0 secs.