from math import sqrt def approx(epsilon): a=sqrt(2)-1 u=0 while abs(a-u)>epsilon: u=1/(2+u) return u