{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

program_1 - CE 335 Computer Assignment 1 An introduction to...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CE 335 Computer Assignment 1 An introduction to Matlab programming: A trigonometric function We will implement a Matlab program to calculate the cosine of a given angle, similar to the built-in function cos. The numerical method we will use is based on the Taylor series for the cosine function: 1 - x 2 /2! + x 4 /4! - x 6 /6! + x 8 /8! - ... which converges to cos(x) for all real values of x . (a) Suppose that x is between 0 and π /2. How many terms in the Taylor series expression would we need to retain in order to compute cos( x ) with an absolute truncation error of at most 10 -10 ? (Invoking the Alternating Series Test may be useful here -- look it up.) (b) Write a Matlab subroutine that asks for a number and uses your findings from (a) to compute its cosine. Verify that it works by computing cos( π /4) and cos( π /3). (c) How many terms in the Taylor series would you need to retain in order to calculate cos(5) to the same accuracy using the approach you just implemented?
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}