Blob


1 #include <u.h>
2 #include <libc.h>
3 #include "map.h"
5 double
6 cubrt(double a)
7 {
8 double x,y,x1;
9 if(a==0)
10 return(0.);
11 y = 1;
12 if(a<0) {
13 y = -y;
14 a = -a;
15 }
16 while(a<1) {
17 a *= 8;
18 y /= 2;
19 }
20 while(a>1) {
21 a /= 8;
22 y *= 2;
23 }
24 x = 1;
25 do {
26 x1 = x;
27 x = (2*x1+a/(x1*x1))/3;
28 } while(fabs(x-x1)>10.e-15);
29 return(x*y);
30 }