Accueil     À propos     Téléchargement     Ressources     Contactez-nous

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

nth_root of num?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
 Date: 1998-12-01 (18:45) From: Claude Marche Subject: Re: nth_root of num?
>>>>> "N Hur" == N Hur <mapnh@maths.bath.ac.uk> writes:

N Hur> Thank you.

N Hur> But running your code for example,

N Hur> 	root_floor 3 (Int 2) (* menaing third_root of 2 *);;

N Hur> gives 1, while what we want is 1.2599210498 ...

Sorry, I misunderstood your question. I though you where interested in
computing the nth root of a big_num. If you are interested in
computing the nth root of a float, I really don't understand why you
are using big nums.

An algorithm for computing the nth root of a float is easy :

let nth_root n x = exp (log(x)/.(float_of_int n));;