Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let accuracy = 0.00001
- let rec iterate x a =
- let diff = x - a*a
- if abs diff <= accuracy then
- a
- else
- iterate x ((a + x/a) / 2.0)
- let newtonSqrt x =
- iterate x (x/2.0)
- let squared = 10.0
- printfn "square root of %A = %A" squared (newtonSqrt squared)
Add Comment
Please, Sign In to add comment