This is a code for finding the root of the equation f(x) = exp(-x) - x
in iteration method. When it runs, it shows the error,
File "fixedpointiteration.py", line 7
i = i+1
^
SyntaxError: invalid syntax
Any solution? Thanks in advance.
i = 1
x[i] = 0
error[i] = 9999
while error[i] >= 0.1:
x[i+1] = exp[-x[i]]
error[i+1] = abs((((x[i+1] - x[i])/(x[i+1])*100))
i = i+1
print x
print error
abs((((x[i+1] - x[i])/(x[i+1])*100))
– Kasra 55 mins agox[i] = 0
is wrong – haifzhan 51 mins ago