Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use matlab to create a function with structure function P = cosTaylor(x_in,n) where is a vector with evenly spaced entries and n is an even
Use matlab to create a function with structure function P = cosTaylor(x_in,n) where is a vector with evenly spaced entries and n is an even integer. The function should evaluate the degree Taylor polynomial of centered at at each point in the vector and store the results in a vectorP. The Taylor polynomial in question is .
Create a function with structure function P-CosTaylor(x_in,n) where x is a vector with evenly spaced entries and n is an even integer. The function should evaluate the nth degree Taylor polynomial of cos x centered at x = 0 at each point in the vector Xin and store the results in a vectorP. The Taylor polynomial in question is cos(1)2 (2i)! Your Function C Reset MATLAB Documentation function P = cosTaylor(xin,n) 2 % Input: xin is an array of x-values 3 % Input: n is an even integer to determine degree of Taylor poly 4 % Output: P s a vector of the y-values of the Taylor polynomial corresponding to the 6 P = zeros (1, length(Xin)); 7 8%use loop to add up the terms in the sum 9 for 10 11 end Code to call your function C Reset 1 %As a check, with x linspace(-1,1,5) and n 4, we get 2%P [0.5417 0.8776 1.0000 0.8776 0.5417] 3cosTaylor(linspace (-1,1,5),4)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