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$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;}

## Recommended textbook solutions #### Numerical Methods for Engineers

7th EditionISBN: 9780073397924 (8 more)Raymond P Canale, Steven C Chapra
762 solutions #### 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 EditionISBN: 9780133942651 (8 more)Randall D. Knight
3,508 solutions 