fixed point iteration issue [closed]
Im having a problem with this code wonder if someone could help me, its a code for fixed point iteration:
def valores(f,p,a,b,xi,n):
var('k,xk,fi,ErAbs,ErRel,ErMet')
a==a
b==b
xi==xi
x1=p(xi)
L=[[k,xk,fi,ErAbs,ErRel,ErMet]]
for i in range (0,n):
L.append([n,xi,x1,er,ea,em])
er = abs(x1-xi)
if xi > 1:
ea = er/xi
else:
ea = er
em = ea*(l*(1-l))
xi=p(xi)
x1 = p(xi)
return (matrix(L))
@interact
def Exp(n = selector(range(0, 11),nrows=1, label="Botão"),f = input_box(default=x*e^x-1), a = input_box(default=0.5), b = input_box(default=1), xi = input_box(default=0.8),p = input_box(default=e^(-x)):
df = diff(f,x)
dp = diff(p,x)
if df(x) > 0:
l = abs(dp(b))
else:
l = abs(dp(a))
show(valores(f,p,a,b,xi,n))
Error showed:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_117.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("QGludGVyYWN0CmRlZiBF\ eHAobiA9IHNlbGVjdG9yKHJhbmdlKDAsIDExKSxucm93cz0xLCBsYWJlbD0iQm90w6NvIiks\ ZiA9IGlucHV0X2JveChkZWZhdWx0PXgqZV54LTEpLCBhID0gaW5wdXRfYm94KGRlZmF1bHQ9\ MC41KSwgYiA9IGlucHV0X2JveChkZWZhdWx0PTEpLCB4aSA9IGlucHV0X2JveChkZWZhdWx0\ PTAuOCkscCA9IGlucHV0X2JveChkZWZhdWx0PWVeKC14KSk6CiAgICBkZiA9IGRpZmYoZix4\ KQogICAgCiAgICBkcCA9IGRpZmYocCx4KQogICAgCiAgICBpZiBkZih4KSA+IDA6CiAgICAg\ ICAgbCA9IGFicyhkcChiKSkKICAgIGVsc2U6CiAgICAgICAgbCA9IGFicyhkcChhKSkKICAg\ ICAgICAKICAgIHNob3codmFsb3JlcyhmLHAsYSxiLHhpLG4pKQ=="),globals())+"\\n")\ ; execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in <module> File "/tmp/tmpWfUq28/___code___.py", line 4 def Exp(n = selector(range(_sage_const_0 , _sage_const_11 ),nrows=_sage_const_1 , label="Botão"),f = input_box(default=x*e**x-_sage_const_1 ), a = input_box(default=_sage_const_0p5 ), b = input_box(default=_sage_const_1 ), xi = input_box(default=_sage_const_0p8 ),p = input_box(default=e**(-x)): ^ SyntaxError: invalid syntax