That's a Taylor expansion. When people write ^ they often mean "raised to the power of", so x^3 means "x raised to the power of 3". (In C and C++, ^ means XOR.)
You would keep subbing in values for "n" or "i" in your function, until the value you are adding is less than what you can store in a value for your precision.
So you would use the end of what was given to you:
(-1)^i*(x^(2*i+1))/(2*i+1)!
You sub in number's from 1 to infinite for i and keep adding the result into a variable.
1 2 3 4 5 6 7 8
double total = 0;
double x;
for(int i = 0; i < 10; ++i) {
total += pow(-1.0, i) * ( pow(x, 2 * i + 1) / factorial(2 * i + 1) );
}
That's how it would look, of coarse you could probably optimize the calculation in some places and that for loop is only for 10 iterations idk how many you would actually need, you should do a comparison and determine the lowest possible precision that can be added to total or do a set number of iterations your choice really.
By the way, L B, silly programmers would prefer something like this:
1 2 3 4 5 6
std::complex<double> const i (0.0, 1.0);
std::complex<double> x (0.25); // Vary from 0 to 2
double sine = (std::pow(i, 4*x-1)+i)/(2*std::pow(i, 2*x));
double cosine = (std::pow(i, 4*x)+1)/(2*std::pow(i, 2*x));
double tangent = (std::pow(i, 4*x-1)+i)/(std::pow(i, 4*x)+1); // Will divide by zero at x = 0.5 or x = 1.5
Or:
1 2 3 4 5 6 7 8
std::complex<double> const i (0.0, 1.0);
std::complex<double> x (0.25); // Vary from 0 to 2
std::complex<double> result = std::pow(i, 2*x);
double sine = result.imag();
double cosine = result.real();
double tangent = sine/cosine;
These functions are of the form sin(x*pi), cos(x*pi) and tan(x*pi).