3 * Cube root, long double precision
9 * long double x, y, cbrtl();
17 * Returns the cube root of the argument, which may be negative.
19 * Range reduction involves determining the power of 2 of
20 * the argument. A polynomial of degree 2 applied to the
21 * mantissa, and multiplication by the cube root of 1, 2, or 4
22 * approximates the root to within about 0.1%. Then Newton's
23 * iteration is used three times to converge to an accurate
31 * arithmetic domain # trials peak rms
32 * IEEE .125,8 80000 7.0e-20 2.2e-20
33 * IEEE exp(+-707) 100000 7.0e-20 2.4e-20
39 Cephes Math Library Release 2.2: January, 1991
40 Copyright 1984, 1991 by Stephen L. Moshier
41 Direct inquiries to 30 Frost Street, Cambridge, MA 02140
47 static long double CBRT2 = 1.2599210498948731647672L;
48 static long double CBRT4 = 1.5874010519681994747517L;
49 static long double CBRT2I = 0.79370052598409973737585L;
50 static long double CBRT4I = 0.62996052494743658238361L;
53 extern long double frexpl ( long double, int * );
54 extern long double ldexpl ( long double, int );
55 extern int isnanl ( long double );
57 long double frexpl(), ldexpl();
62 extern long double INFINITYL;
93 /* extract power of 2, leaving
94 * mantissa between 0.5 and 1
98 /* Approximate cube root of number between .5 and 1,
99 * peak relative error = 1.2e-6
101 x = (((( 1.3584464340920900529734e-1L * x
102 - 6.3986917220457538402318e-1L) * x
103 + 1.2875551670318751538055e0L) * x
104 - 1.4897083391357284957891e0L) * x
105 + 1.3304961236013647092521e0L) * x
106 + 3.7568280825958912391243e-1L;
108 /* exponent divided by 3 */
120 { /* argument less than 1 */
132 /* multiply by power of 2 */
135 /* Newton iteration */
137 x -= ( x - (z/(x*x)) )*0.3333333333333333333333L;
138 x -= ( x - (z/(x*x)) )*0.3333333333333333333333L;