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

VerifiedStep 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

## Create an account to view solutions

By signing up, you accept Quizlet's Terms of Service and Privacy Policy

## Recommended textbook solutions

#### Numerical Methods for Engineers

7th Edition•ISBN: 9780073397924 (8 more)Raymond P Canale, Steven C Chapra762 solutions

#### Fundamentals of Electric Circuits

6th Edition•ISBN: 9780078028229 (9 more)Charles Alexander, Matthew Sadiku2,120 solutions

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

4th Edition•ISBN: 9780133942651 (8 more)Randall D. Knight3,508 solutions

#### Advanced Engineering Mathematics

10th Edition•ISBN: 9780470458365 (8 more)Erwin Kreyszig4,134 solutions