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

Atividades #1.3
Vive como se fosse morrer amanhã.
Estude como se fosse viver para sempre.
Einstein

Atividade #1.3.02

  • A função \(f_{1}(x)=x^2+x-6\) tem os raízes: 2 e -3. Para quais pontos iniciais: \([-5.0,-4.0,-1.0,1.0,3.0,5.0]\) o algoritmo ponto fixo converge usando a função iterativa \(\varphi_1,\) respectivamente \(\varphi_2\) ? Em quantas iterações?
  • Python Listing: ../../Run.Fixed_Point2.py.
    from Fixed_Point import *
    from Functions2 import *
    
    phis=[phi1,phi2]
    x0s=[-5.0,-4.0,-1.0,1.0,3.0,5.0]
    
    n=1
    for phi in phis:
        for x0 in x0s:
            xs=Fixed_Point(f1,phi,x0,1.0E-6)
            #print f
            print "phi"+str(n)+": "+str(x0),len(xs),xs[ len(xs)-1 ]
        n+=1
    
    phi1: -5.0 14 2.00000008479
    phi1: -4.0 14 2.00000007407
    phi1: -1.0 13 1.99999984059
    phi1: 1.0 13 1.99999994303
    phi1: 3.0 13 2.00000006306
    phi1: 5.0 14 1.99999994303
    phi2: -5.0 39 -3.00000029069
    phi2: -4.0 37 -3.00000038153
    phi2: -1.0 41 -2.99999969854
    phi2: 1.0 45 -2.99999964272
    phi2: 3.0 46 -2.99999964272
    phi2: 5.0 44 -2.99999964272
    
    
    Output from: /usr/bin/python ../../Run.Fixed_Point2.py
    Messages:
    0 secs.