in matlab We have learned in class how we can use infinite series to estimate a
ID: 3110452 • Letter: I
Question
in matlab
We have learned in class how we can use infinite series to estimate a finite value. For the sine of a given value x, i.e., sin(x), we can estimate its value using an infinite series given by sin (x) = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! - Write a function called mySin which takes x as an input and returns the computed value of sin(x). Do not use the built-in MATLAB function sin() rightarrow zero points if you do!! We have done this in class, all you have to do is convert to a function. Steps: (1) setup a running sum, (2) set your tolerance, (3) compute running sum, and (4) terminate once you've reached your 'exit' criterion i.e. once your tolerance has been met.Explanation / Answer
function y=mySin(x)
N=100;
for n=1:N
An(n) = (-1)^(n-1)*x^(2*(n-1)+1)/factorial(2*(n-1)+1);
end
y=sum(An);
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.