Question: Write a function m-file to calculate the approximated cosine function which can be evaluated by the following infinite series - equation cos x = 1

Write a function m-file to calculate the approximated cosine function which can be evaluated by the

following infinite series - equation

cos x = 1 - ( x2/2! ) + ( x4/4! ) - ( x6/6! ) + ..... + ((-1)(n+1)x2(n-1))/(2(n-1))!

Here are requirements for the function m-file.

- Parameter lists (inputs): x value (in radian), and desired error percentage. If the real error per-

centage is less than the desired error percentage, the loop (addition) will stop.

- Return value (outputs): approximated value, real error percentage, and number of iterations

- Function name: Approx_Cos_yourEmailAccount

Using a script m-file which will call the Approx_Cos_yourEmailAccount function, save outputs with following given inputs.

- x = pi/12 and %error = 1%. Save it on EX1_11.dat

- x = pi/12 and %error = 0.1%. Save it on EX!_12.dat

- x = pi/6 and %error = 1%. Save it on EX1_13.dat

- x = pi/6 and %error = 0.1. Save it on EX1_14.dat

- x = pi/6 and %error = 0.01%. Save it on EX1_15.dat

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!