Question
The Maclaurin series expansion for the cosine function up to some number of terms is given by cos(x) = 1 x2 2! + x4 4!
The Maclaurin series expansion for the cosine function up to some number of terms is given by cos(x) = 1 x2 2! + x4 4! x6 6! + x8 8! xn n! , where x is the angle in radians and n! = n (n 1) (n 2)... 1 denotes the factorial of n. Note that 0! = 1. For example, the cosine approximations for one, two, and ve terms can be obtained as follows: cos(x) = 1 cos(x) = 1 x2 2! cos(x) = 1 x2 2! + x4 4! x6 6! + x8 8! Write a function approxCosineFunction that takes scalar input arguments x and the number of terms t, and returns the approximate value of cos(x). The function is invoked as follows: approx = approxCosineFunction(x, t); Use MATLABs 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 MATLABs cos function.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started