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