Hi I am trying to write a program that requires a repeat to infinity. However I am not sure how to do this I am trying to use the Taylor series to find the sine of an angle and the series is:
sin(x) = x - (x^3)/3! + (x^5)/5! - (x^7)/7!...
This pattern the repeats forever I have tried using a while (true) statement but I cant seem to get that to work how can I get this to work
# include <iostream>
#include <cmath>
usingnamespace std;
int factorial (int x)
{ if (x ==1)
return 1;
return ( x * factorial(x-1));
}
int main ()
{
double angle;
int n = 0;
int x = 1;
cout << "Please enter the value of the angle in radians";
cin >> angle;
cout << "The sine of the angle is " << sin(angle) << endl;
cout << "using the taylor series the sine of the angle is " << endl;
while (true){
angle - (pow (angle,3+2*n)/(factorial(3+2*n++))) << endl;}
return 0;
}