(* Moyenne arithmético-géométrique avec test au but *) let rec mag_but x y peu= let arith p q= (p+.q)/.2. and geom p q= sqrt(p *.q) in if abs_float(x-.y) x |n -> (a (n-1)+.(b (n-1)))/.2. and b = function |0 -> y |n -> sqrt(a (n-1)*.(b (n-1))) in print_float (a p); print_string " "; print_float (b p) ;; (* mag_but 1. 10. 1e-10;; - : float = 4.25040709493 mag 1. 10. 5;; 4.25040709493 4.25040709493- : unit = () *)