Problem Statement: Given a number find its square root.
Solution: is to use newton-raphson method.
let input number be num and its square root be x
then x² = num
x² – num =0;
f(x) = 0
where f(x) = x² – num
according to newton-raphson
xn+1 = xn – f(x)/f’(x)
where xn+1 and xn are approximate roots for equation f(x)=0
and f’(x) is derivative of f(x) with respect to x
thus f’(x) = 2*x
According to this method gets xn+1 is more accurate than xn with each iteration
we run these iteration until error(x²-num) is within some bound epsilon