Version française
Home     About     Download     Resources     Contact us    
Browse thread
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: -- (:)
From: John Whitley <whitley@c...>
Subject: Re: nth_root of num?
Claude Marche writes:
 > An algorithm for computing the nth root of a float is easy :
 > 
 > let nth_root n x = exp (log(x)/.(float_of_int n));;

Alternatively, one could use the (**) float exponentiation operator:

let nth_root n x = x ** (1.0 /. n);;

-- John