* This version is based on a single iteration Halley's method (see https://en.wikipedia.org/wiki/Halley%27s_method)
* with a seed provided by a bit hack approximation. It should offer 15-16 bits precision and be three times
* faster than pow(x, 1/3). In some test, between -500 and +500, the largest relative error was 1.2e-4.
* Source: http://metamerist.com/cbrt/cbrt.htm
* Source: Otis E. Lancaster, Machine Method for the Extraction of Cube Root Journal of the American Statistical Association, Vol. 37, No. 217. (Mar., 1942), pp. 112-115.
* and http://metamerist.com/cbrt/cbrt.htm
*
* Please benchmark your code before deciding to use this!!
* @param x argument
...
...
@@ -203,7 +202,7 @@ namespace Optim {
inlinedoublecbrt(doublex){
constdoublea=nth_rootd<3>(x);
constdoublea3=a*a*a;
constdoubleb=a*(a3+x+x)/(a3+a3+x);
constdoubleb=a*((a3+x)+x)/(a3+(a3+x));
returnb;//single iteration, otherwise set a=b and do it again