### taylor series to compute sin, cosine and tan

#include <iostream>
#include <cmath> // for pow() function

using namespace std;

// Recursion method : http://web.eecs.utk.edu/~cs102/lectures/recursion.html
float factorial(float number)
{
if (number == 0) return 1;
return number * factorial(number-1);
}

{
float radians = (degree / 360) * (2.0 * M_PI);
}

/*
* Refer here for formulae : http://www.youtube.com/watch?v=dp2ovDuWhro
*/
{
float result = 0.0;

for(int x=1; x<aprox; x++)
{
float firstPart = pow (-1, (x+1)); //(-1)^n+1
float secondPart = pow(radian,((2*x)-1)); // x^2n-1
float thirdPart = factorial((2*x)-1); // (2n-1)!
result = result + firstPart*(secondPart/thirdPart);
}

cout<<"Result = "<<result<<endl;
}

int main()
{
return 0 ;
}

So I see that you implemented sin. You could use some improvements there as well. pow(-1,(x+1)) you can do instead:
 `` `` ``firstPart=((x+1)%2==0)?1:-1;``

The other comment is that you can compute the full term in the expansion at step x, as the term at step x-1 multiplied with -radian*radian/(1+2*x), kind of similar to the factorial implementation.

The formula for cos you can find it here http://www.wolframalpha.com/input/?i=taylor+series+cos+x
I dont understand. Can you help me to explain abit detailed?
Say for example for cos(x)=sum_k (-1)^k*x^(2k)/(2k)! The first term is for k=0, (-1)^0*x^0/0!=1.
If you look at the ratio between the last term of the sum at step k, and at step k-1, you see that it is -x^2/(2k)/(2k-1). I just noticed that I forgot a term in my previous comment.

 ``1234567891011`` ``````int cos(int x) { int t = -x*x/2; int sum = 1 + t; for(int i=2;i<20;++i) { t*=-x*x/(2*i*(2*i-1)); sum+=t; } return sum; }``````