Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The sine function can be evaluated by the following infinite series: Write a fun

ID: 3568793 • Letter: T

Question

The sine function can be evaluated by the following infinite series: Write a function approx_sine that takes as input two parameters, x and threshold, to perform the following task. Starting with the simplest approximation sin(x) = x, add terms one at a time to improve this estimate until Your function must return two output values: the approximate value of sin(r) and the number of terms that were needed to obtain this value subject to the desired error threshold. The following is an example of function behavior for x = pi/5. Note that the terms value returned by the function only counts the number of terms added to the starting approxima-tion of sin(x).

Explanation / Answer

function [approx,term] = ApproxSin2 (x,threshold)
error=1;
n=1;
count=0;
while error >= threshold do
%x -x^3/3! +x^5/5! ...
count=count+1;
terms(count)=(-1)^(count+1)*(x^n)/factorial(n);
SINx=sum(terms);
n=n+2;
error=abs((sin(x)-SINx)/sin(x))*100;
end_while
approx = SINx;
term = count;
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote