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

Newton-Raphson
Even a stopped clock is right once a day.
English proverb
< Ponto Fixo | Implementação | Atividades 1.4: >

Implementação

Python Listing: ../Newton_Raphson.py.
def Newton_Raphson(f,df,x0,eps=1.0E-6,maxiteration=100):
    #List of x-values
    
    xk=x0
    xs=[xk]
    
    stop=False
    iteration=0
    while (not stop):
        xk1=xk-f(xk)/df(xk)
        
        if ( abs(f(xk))<eps   ): stop=True
        if ( abs(xk1-xk)<eps   ): stop=True
        if ( iteration>maxiteration ): stop=True
        
        xk=xk1
        xs.append(xk)
        iteration+=1

    return xs
< Ponto Fixo | Implementação | Atividades 1.4: >
Messages:
0 secs.