import evaluar
from pylab import *
from numpy import *
def puntofijo(po,TOL, N):
vectorx = zeros (N, Float64)
vectory = zeros (N, Float64)
i = 1
while i<=N :
vectorx[i-1] = po
Evaluar.dicc_seguro['x']=po
fp = eval(Evaluar.funcion, {"__builtins__":None}, Evaluar.dicc_seguro)
vectory[i-1]=fp
if fabs(po-fp):
print "La raiz buscada es: ",po, "con", i-1, "iteraciones"
sys.exit()
i = i+1
po = fp
quit() [vectorx,vectory]
def dibujar(po,TOL, ):
x = arange(po-2,po+2,0.1)
vectores=puntofijo(po, TOL, Y)
subplot(211)
plot(x, eval(Evaluar.funcion), linewidth=1.0)
xlabel('Abcisa')
ylabel('Ordenada')
title('Metodo Punto Fijo con f(x)= x - ' + Evaluar.funcion)
grid(True)
axhline(linewidth=1, color='r')
axvline(linewidth=1, color='r')
subplot(212)
plot(vectores[0], vectores[1], 'k.')
xlabel('Abcisa')
ylabel('Ordenada')
grid(True)
axhline(linewidth=1, color='r')
axvline(linewidth=1, color='r')
show()
Felipe_1
0
Newbie Poster
Recommended Answers
Jump to Postdef puntofijo(po,TOL, N): vectorx = zeros (N, Float64) vectory = zeros (N, Float64) i = 1 while i<=N : vectorx[i-1] = po Evaluar.dicc_seguro['x']=po fp = eval(Evaluar.funcion, {"__builtins__":None}, Evaluar.dicc_seguro) vectory[i-1]=fp if fabs(po-fp): print "La raiz buscada es: ",po, "con", i-1, "iteraciones" sys.exit() i = i+1 po = fp …
All 4 Replies
Schol-R-LEA
1,446
Commie Mutant Traitor
Featured Poster
Felipe_1
0
Newbie Poster
Schol-R-LEA
1,446
Commie Mutant Traitor
Featured Poster
rubberman
1,355
Nearly a Posting Virtuoso
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.