I have a homework in C. We have to write our own asin()
function with Taylor method, and we can't use math.h
It works fine, but once I put higher count of iterations(int i)
, it returns NaN
(Not a Number), and when I use low count of i
, the number is not exact. Can anyone help me with this?
double my_asin(double x)
{
int i = 0;
double vypocet = x;
double y = vypocet;
for(i=1;i<=10000;i++)
{
vypocet*=((x*x)*(2*i-1)*(2*i-1))/((2*i)*(2*i+1));
y+=vypocet;
}
printf("my_asin = %.10e\n", y);
return y;
}
EDIT: Thank you all! finished it :)