Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MATLAB - PLS HELP 1. (a) Write a function called trigseries which takes as inputs x (a vector of x-values), n (number of terms in
MATLAB - PLS HELP
1. (a) Write a function called trigseries which takes as inputs x (a vector of x-values), n (number of terms in the series), and options (a text string which can be sine, cosine or both). The second two inputs should be optional (with default values n=10, options='both', as appropriate). trigseries should have two outputs: the computed value of the appropriate trigonometric function(s) and the l2 error norm compared with matlab's built-in trigonometric functions (use the command norm). trigseries should use two subfunctions sine series and cosine series which ap- proximate the value of the associated functions at x using the appropriate Taylor series centred around x = 0. (b) Test trigseries using an input x of 10 equally spaced values between 0 and 7/2. Plot the output for both sine and cosine compared with the built-in function values. Test that your function works properly with different numbers of input variables. (c) Make a log-log plot of the absolute value of the error as a function of the number of terms in the Taylor series for sin(x) for n = 1, ..., 120 terms for x = n/2 and 3 = 46/2. Why does the error eventually become constant? Why do the two values of I give different minimum errors? Explain the difference in terms the Taylor remainder theorem and loss of floating point precision by plotting the magnitude nth term in the series for n=1,..., 120 termsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started