Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.5000Step 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