Im still working on this one, with not much luck.
(assuming even values of n only) I now get the correct answer using values of x=0.1 and 0.2 with a y value 0.01. Any x > 0.2 causes the program to get stuck in calculation. Increasing the value of y means i can get (not entirely accurate) values for larger x.
Is it that the program is just too computationally long for a large n value? Is there some way to simplify the program that i am not aware of?
thanks for looking (and btw my original post said to take cos(y) = 1 - x^2/2, but it is infact y^2/2 rather than x.
Code:
float sin_recur(float n, float y, float result)
{
float x = n*y;
if(x==0)
return 0;
else if(x <= 0.00001)
return x;
else
{
printf("%f\n", n);
return result = (2 - y*y)*sin_recur((n-1), y, result) - sin_recur((n-2), y, result);
}
}