ok this is what i have;
from math import *
x=input("What value will you give x?:")
n=input("Please set a maximium amount of iterations?:")
for i in range (n):
x = x - ((x-cos(x))/(1 + sin(x)))
break
y =x
if (y-x) <= 10**-8:
print y
elif (y-x) > 10**-8:
continue
still not working..advice??
Please use code tags when posting code in this forum. To use code tags wrap your code in these guys:
[code=python]
# Code in here
[/code]
Just to be nice I'll wrap your code for you:
from math import *
x=input("What value will you give x?:")
n=input("Please set a maximium amount of iterations?:")
for i in range (n):
x = x - ((x-cos(x))/(1 + sin(x)))
break
y =x
if (y-x) <= 10**-8:
print y
elif (y-x) > 10**-8:
continue
See how much nicer that looks? And indentation is not lost!
So first thing: remove the break and the continue statements.
Next,
y = x should be assigned at the end of your loop.
That should get you a little closer
Reputation Points: 355
Solved Threads: 292
Veteran Poster
Offline 1,102 posts
since Jul 2008