It is declared as: double sine(double X); it will return the sine of X measured
ID: 3534525 • Letter: I
Question
It is declared as: double sine(double X);
it will return the sine of X measured in radians. it will return the "double" value Not-A-Number for all error conditions. The value of sine is to be approximated using a power power series. Expand each power series approximation until you reach a term whose absolute value is less than a specified epsilon (1.0e-8). The term should not be included in the approximate value of the power series. This is what I have so far but it doesn't work, can anyone help? The power(...) and the factorial(...) are also functions I made but they work.
double sine(double X)
{
double Num;
double N;
double D;
double P;
double epsilon = 0.00000001;
if (X == 0)
{
Num = 0;
}
else
{
for (unsigned A=0; (power(X,2*A+1)/factorial(2*A+1)) > epsilon; A++)
{
N = power(-1,A);
D = factorial(2*A + 1);
P = power(X,2*A + 1);
Num = (N/D)*P;
}
}
return Num;
}
Explanation / Answer
double sine(double X)
{
double Num;
double N;
double D;
double P;
double epsilon = 0.00000001;
if (X == 0)
{
Num = 0;
}
else
{
for (unsigned A=0; (power(X,2*A+1)/factorial(2*A+1)) > epsilon; A++)
{
N = power(-1,A);
D = factorial(2*A + 1);
P = power(X,2*A + 1);
Num+= (N/D)*P;
}
}
return Num;
}
in the answer i have highlighted ur mistake.........and corrected it plz consider it......and surely it will run
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.