Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions