Question: Consider the expression where . The series approximates the sine function , i . e . , . . We can compute the sum using

Consider the expression
where .
The series approximates thesinefunction, i.e.,..
We can compute the sum using the recurrence relations and with initial values and .
Write a function named compute_sine_sum_errthat accepts two input variables, a real value xused in the sum, and the positive real value errorTol.
Add commands to the function that compute the expression until it converges to within errorTol. Specifically, convergence occurs when the relative absolute error is less then errorTol. Do not use the factorialfunction.
Assign the value of the sum to the output variable S.
Assign the number of terms in the sum to the output variable noTerms. Notice that noTermswill be equal to , because the sum starts indexing at 0.
If errorTolis negative, then assign the empty vector value []to S, and assign -1to noTerms.
Note the value of the variables xand errorTolare defined as inputs to the function. Do not overwrite these values in your code. Be sure to assign values to the output variables S, and noTerms.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!