let newton = function f, a, b ->
let
f' = deriv (f)
in
let
x0 = if (f (b) -. f (a)) *. (f' (b) -. f' (a)) > 0. then b else a
and
h = function x -> x -. f (x) /. f' (x)
in
let rec
iter = function x -> if abs_float (f (x)) < 1e-7 then x else iter (h (x))
in
iter (x0)