The MacLaurin series of cos() is:
cos(x) := Sum(i = 0 to Inf) [((-1)^i / (2*i)!) * x ^ (2*i)]
[EDITED, "2*i!" replaced by "(2*i)!"]
If you want a numerical output, it is the direct approach to calculate it numerical directly:
function y = cosMacLaurin(x, k)
S = 0;
for i = 0:k
S = S + ...
end
end
I leave the "..." up to you, because I assume that this is a homework question.
Best Answer