Compare commits

...

2 Commits

Author SHA1 Message Date
Kat R. 6e8348fca6 Removed a circular dependency for pow 2022-10-28 00:05:56 -05:00
Kat R. f07528dace Why am I doing exp(24)?! It's a constant!!! 2022-10-27 23:57:29 -05:00
2 changed files with 20 additions and 2 deletions

View File

@ -15,7 +15,7 @@ double _agm(double x, double y) {
}
double log(double x) {
double s = x * exp2(24);
double s = x * 16777216;
double nat_log = (M_PI / (2 * _agm(1, 4/s))) - (24 * M_LN2);
return nat_log;
}

View File

@ -9,10 +9,28 @@ typedef union {
} parts;
} _dbl_cast;
double _iexp2(int x) {
double result = 1.0;
if(x > 0) {
for(int i = 0; i < x; i++) {
result *= 2;
}
}
else if(x < 0) {
for(int i = 0; i > x; i--) {
result /= 2;
}
}
return result;
}
/*
First gets an initial estimate then refines it using the Bakhshali method
*/
double sqrt(double x) {
_dbl_cast S = { .d = x };
double estimate = (0.5 + 0.5 * S.parts.mantissa) *
exp2(S.parts.exponent - 1023);
_iexp2(S.parts.exponent - 1023);
double a_n, b_n;