Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB - please help!!! (a) Write a function called trigseries which takes as inputs x (a vector of x-values), n (number of terms in the

MATLAB - please help!!!

(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 approximate 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 pi/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=pi/2 and x=4pi/2. Why does the error eventually become constant? Why do the two values of x give different minimum errors? Explain the difference in terms of the Taylor remainder theorem and loss of floating-point precision by plotting the magnitude nth term in the series for n=1,...,120 terms.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions