i was going to use the taylor series of sqrt(x) to calculate it, but it only converged for a pretty small neighborhood of values, so i went looking for other methods of calculating it. then, i came across the identity sqrt(x) = e^(1/2)ln(x), which reduced calculating the square root to the problem of calculating a logarithm, which i knew had an easy to derive taylor series. so, i derive the taylor series for ln(x), but then it would only converge for an input between 0 and 2. at first i thought i was back where i started, but after noticing

this on wikipedia (just before the "high precision" section) i realized i could manipulate the input so one half would be in a range i could compute for, and the other half was computable from constants in math.h. here's the ln() and sqrt() functions:

double ln(register double x)
{
register int n = 1;
register int exponent = 0;
double result = 0.0;
register double sum = 0.0;
while(!(0<x && x<2))
{
x/=10;
exponent++;
}
for(; n<=100; n++)
{
sum += (1.0/n)*pow(-1,n+1)*pow(x-1,n);
}
result = sum + exponent*M_LN10;
return result;
}
double my_sqrt(double x)
{
double result = 0.0;
result = pow(M_E, 0.5*ln(x));
return result;
}