Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Numerical Methods & MatLab! Please show code and outputs clearly as well as an explaination. Thank you in advance!!! 3 Taylor Series in MATLAB (25

Numerical Methods & MatLab! Please show code and outputs clearly as well as an explaination. Thank you in advance!!! 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 cos x using this Taylor series. The function takes the input x in radians and return cos(x) approximation as output. \[ \text { function cos_ } x=\operatorname{cosTaylor}(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 used 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_2

Step: 3

blur-text-image_3

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 M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions