- Feb 29, 2004
- 1,031
- 0
- 76
Hello. I'm coding a very small program in C++ to calculate the sine of an angle, using the Taylor series equation.
The taylor series goes: sin(x) = x - x^3/3! + x^5/5! - x^7/7! ...
Anyways, I need to use doubles to hold all the decimal places (for pi, and for x, because x needs to be in radians), but, I always get a compiler error telling me (paraphrased) that I can't use the '^' operator with doubles.
Is there anyway to raise a number to a power, without having to go: (x*x*x*x....)?
Oh, and is there any way to do the '!' without putting: (7*6*5....) ?
Thanks
- Ben
The taylor series goes: sin(x) = x - x^3/3! + x^5/5! - x^7/7! ...
Anyways, I need to use doubles to hold all the decimal places (for pi, and for x, because x needs to be in radians), but, I always get a compiler error telling me (paraphrased) that I can't use the '^' operator with doubles.
Is there anyway to raise a number to a power, without having to go: (x*x*x*x....)?
Oh, and is there any way to do the '!' without putting: (7*6*5....) ?
Thanks
- Ben