Menu

(Solved) : Write Function M File Calculate Approximated Cosine Function Evaluated Following Infinite Q43989457 . . .

Write a function m-file to calculate the approximated cosinefunction 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 desirederror 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 errorpercentage, and number of iterations

– Function name: ’ Approx_Cos_yourEmailAccount’

Using a script m-file which will call theApprox_Cos_yourEmailAccount function, save outputs with followinggiven 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

Expert Answer


Answer to Write a function m-file to calculate the approximated cosine function which can be evaluated by the following infinite s…

OR