How do I do this?

Now onto the double my sine( double x ) function.
1. Use fmod to find the value of x mod 2*PI. 2. If the new x is negative, add 2*PI to it. (This is to ensure that 0 ≤ x < 2π). This first two steps use the fact that sine and cosine are periodic functions with period 2π.
3. Using this new x, find the reference angle r and find the quadrant q.
4. Use the reference angle to compute the sum
s = r − (r^3 / 3!) + (r^5 / 5!) − (r^7 / 7!) + ... − (r^1499 / 1499!) + (r^1501 / 1501!)
which goes up to 1501.
5. Depending on the quadrant q, the function will return either s or -s.
Last edited on
Again, what have you coded?
#include "std_lib_facilities.h"
int main ()
{
double x;
char finish;
while (true)
{
cout << "Press a letter to continue or '0' to quit.\n";
cin >> finish;
if (finish == '0')
{
cout << "The program has finished.\n";
break;
}
else
{
double mycos, c;
cin >> x;
mycos = ;
c = cos(x);

cout << "The value of mysine is " << mycos << ".\n"
<< "The value of sin(x) is " << c << ".\n";

double mycos(double x)
{

}
}
}


I dont know how to compute the sum itself inside the loop.
Last edited on
Topic archived. No new replies allowed.