Question: what is wrong with my matlab code clc; function approx = cosineApprox(x,t) approx = 1 for i=1:1:t-1 nextTerms = (-1)^i*(x^(2*i))/factorial(2*i); approx = approx + nextTerm;


what is wrong with my matlab code
clc;
function approx = cosineApprox(x,t)
approx = 1
for i=1:1:t-1
nextTerms = (-1)^i*(x^(2*i))/factorial(2*i);
approx = approx + nextTerm;
end
end
x = 2*pi/3;
actual = cos(x);
disp("original value:");
disp(actual);
t = input("number of terms:");
approx = cosineApprox(x,t);
disp("approximate value:");
disp(approx);
-0.4996 >> approx = approxcosineFunction(x, 10) approX - -0.5000
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
