?from math import * def f(x): return x*x-2.0 xpp = 2 xp = z = 1.5 N = 100 eps = 1.0e-15 i = 0 abserr = abs(z) while i<=N and abserr>eps*abs(z): z = xp - f(xp)*(xp-xpp)/(f(xp)-f(xpp)) abserr = abs(z-xp) print("%3i, %1.16f, feil: %1.16f" %(i, z, abserr)) i = i + 1 xpp = xp xp = z print("%i iterasjoner: m=%1.16f feil=%e " %(i, z, abserr/abs(z))) print ("Innebygd verdi=%1.16f" %(sqrt(2.0)))