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

Posição Falsa
Life is a mystery to be lived.
Not a problem to be solved.
Søren Kierkegaard.
< Bisecção | Implementação | Testes >

Implementação

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

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

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

    return xs
< Bisecção | Implementação | Testes >
Messages:
0 secs.