Question: Question 1 ( 5 0 marks ) : For the following Maclaurin series: c o s x = n = 0 ( - 1 )

Question 1(50 marks):
For the following Maclaurin series:
cosx=n=0(-1)n(2n)!x2n=1-x22!+x44!-cdots
i. Write a MATLAB function, named my_fun, that will accept x and N as inputs and produce one output, corresponding to the approximated value of cos(x) given in the equation above. You must use for-loops.
ii. Test your function for x=0.3 and N=3 and store the result in a variable named test_fun.
iii. For x=0.3, call the my-fun function six times, corresponding to N=0,1,2,3,4 and 5. Use a for-loop to solve this part and store the result of the function calls in an array named test 2 fun.
iv. Plot a bar graph showing the absolute error difference between the results for all calls and the actual value of cos(x). Add a descriptive title and labels.
v. Compare your performance for both functions using )=0.5,N=(10. Call each function 100 times and time them using the commands tic and toe.
 Question 1(50 marks): For the following Maclaurin series: cosx=n=0(-1)n(2n)!x2n=1-x22!+x44!-cdots i. Write

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!