I got stuck and I don't know how to find how many iterations are needed for Newton's method. Where should I put it? Should I put it in a while loop?
tolerance = 10e-6
def newton(funkcia,derivacia,x):
def f(x):
f=eval(funkcia) #precita mi string a prehodi to na rovnicu s variables
return f #zapamataj si vysledok=return, aby sme ho mohli dalej pouzit
def df(x):
df=eval(derivacia)
return df
while f(x) < -tolerance or f(x) > tolerance: #dopln pocet interacii
x=x-(f(x)/df(x)) #vzorec{}
print(f"koren je v bode {x}")
newton("x**2 - 2","2*x", 20 )