Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3 Taylor Series in MATLAB (25 points) The function f(x)=cos(x) can be represented in a Taylor series as follows (where x is in radians): cos(x)=12!x2+4!x46!x6+=n=0(2n)!(1)nx2n=n=0an

image text in transcribed
3 Taylor Series in MATLAB (25 points) The function f(x)=cos(x) can be represented in a Taylor series as follows (where x is in radians): cos(x)=12!x2+4!x46!x6+=n=0(2n)!(1)nx2n=n=0an Write a function file cosTaylor.m that computes the value of cosx using this Taylor series. The function takes the input x in radians and return cos(x) approximation as output. \[ \text { function cos_ } x=\operatorname{cosTay} \operatorname{lor}(x) \] The program should use a loop structure to add each term of the summation. If an is the nth term in the series, the sum Sn of the n terms is Sn=Sn1+an. In each loop iteration calculate the estimated error E given by: E=Sn1SnSn1 Repeat the loop until E is smaller than 0.00001 OR the number of terms that have already been added is not greater than 30 . The function should print on screen the number of terms nsed in the summation when the loop ends. - Report the MATLAB script file and the output of following function calls: cosTaylor (pi/4). cosTaylor (17pi/5), and cosTaylor (22) - Compare the outputs against the cos () function which is predefined in MATLAB: cos (pi/4), cos(17pi/5), and cos(22). Hint; Use while-end loop. You may use break keyword if needed and the factorial () function to calculate the denominator (2n)! in an

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago