Question: f(x) = x - x^3/3! + x^5/5! + Write a MATLAB function called my_sine that uses the Taylor series expansion to evaluate sin(x) at a

f(x) = x - x^3/3! + x^5/5! + Write a MATLAB function called my_sine that uses the Taylor series expansion to evaluate sin(x) at a user-provided x-value, to a user-defined accuracy tol, which specifies the maximum relative true error (i.e." the relative error compared against the built-in function sin(x)). Inputs: x The x-value to evaluate. tol The tolerance to which the sin(x) function should be evaluated. Outputs: f The estimate of sin(x) n The number of terms in the series required to achieve the desired accuracy. Driver: hw2_5.m Prepare a figure that plots the number of terms required vs. log_10tol for x = 1, x = 5, x = 10, and x = 20. Use a logspace-generated list of tolerances ranging from tol = 1 (100% error) to to1 = 16-9. Your plot should include proper labels, a title, and a legend
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
