Question: What part of my code is wrong?? 3. (10 points) The Maclaurin series expansion for the cosine function up to some number of terms is

 What part of my code is wrong?? 3. (10 points) TheMaclaurin series expansion for the cosine function up to some number of

What part of my code is wrong??

3. (10 points) The Maclaurin series expansion for the cosine function up to some number of terms is given by 46 Tl where x is the angle in radians and n! = n (n-1) x (n-2) . . . 1 denotes the factorial of n. Note that 0,-1. For example, the cosine approximations for one, two, and five terms can be obtained as follows: cos(2) COST- 2! cos(z) = 1-2, + Write a function approxCosineFunction that takes scalar input arguments x and the number of terms t, and returns the approximate value of cos(r). The function is invoked as follows approx = approxCosineFunction(x, t); Use MATLAB's factorial function to compute the factorial values. Assume that x is in radians Your code should use MATLABs built-in vector operations to solve this problem. You must not use for and while loops, or MATLAB's cos function The values returned by MATLAB's cos function, which we will consider the gold standard, for some example values of x are >> actual - CoS (x) actual - 0.5000 >> x = pi/3; >> actual - cos (x) actual = 0.5000 Since the approxCosineFunction function is only approximating the cosine value, the ap- proximation will get closer to the actual value as we increase the number of terms. Examples of correct function behavior for various values of x and t follow: >> actual = cos(x) actual - 0.5000 >> approx - approxCosineFunction (x, 2) approx = 1.1932 >> approx - approxCosineFunction (x, 5) approx =

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!