i need matlab code for the question attached It should be in
i need matlab code for the question attached..
It should be in working condition and also show the output..
Solution
clc
clear;
n=-1;
x=pi/4;
cosine=0;
for i=1:1000,
y=cosine;
n=n+1;
cosine=cosine+((-1)^n*x^(2*n))/(factorial(2*n));
e=abs((cosine-y)/cosine);
end
disp(\'error\');
disp(e);
disp(\'cosine(x)\');
disp(cosine);
result:
error
0
cosine(x)
0.7071
