Question

Develop, debug, and document a program in either a high-level language or a macro language of your choice. Employ the library function for the sine in your computer to determine the true value. Have the program print out the series approximation and the error at each step. As a test case, employ the program to compute sin(1.5) for up to and including the term

x15/15!x^{15}/15!

Interpret your results.

Solution

Verified
Step 1
1 of 2
#include <stdio.h>
#include <math.h>

int main(void)
{
int n; double x;
printf("n="); scanf("%d", &n);
printf("x="); scanf("%lf", &x);
int i, sign=1;
long int fact=1;
double s=0, powx=x,e;
for(i=1;i<=n;i+=2)
{
if (i>1)
{
powx*=x*x;
fact*=i*(i-1);
}
s+=sign*powx/fact;
sign=-sign;
e=(sin(x)-s)/sin(x);
printf ("approximation for sin x: %g ",s);
printf ("error=%g ",e);

}
return 0;
}

Create an account to view solutions

By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Continue with GoogleContinue with Facebook

Create an account to view solutions

By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Continue with GoogleContinue with Facebook

Recommended textbook solutions

Numerical Methods for Engineers 7th Edition by Raymond P Canale, Steven C Chapra

Numerical Methods for Engineers

7th EditionISBN: 9780073397924 (8 more)Raymond P Canale, Steven C Chapra
762 solutions
Fundamentals of Electric Circuits 6th Edition by Charles Alexander, Matthew Sadiku

Fundamentals of Electric Circuits

6th EditionISBN: 9780078028229 (9 more)Charles Alexander, Matthew Sadiku
2,120 solutions
Physics for Scientists and Engineers: A Strategic Approach with Modern Physics 4th Edition by Randall D. Knight

Physics for Scientists and Engineers: A Strategic Approach with Modern Physics

4th EditionISBN: 9780133942651 (8 more)Randall D. Knight
3,508 solutions
Advanced Engineering Mathematics 10th Edition by Erwin Kreyszig

Advanced Engineering Mathematics

10th EditionISBN: 9780470458365 (8 more)Erwin Kreyszig
4,134 solutions