The function cos(x) can be approximated using the following series expansion:
Write a MATLAB function called seriesCos that takes a single scalar argument, x, uses the above formula to compute cos(x), and returns the result. Your function should use a while loop and continue adding terms to the series until the absolute value of the difference between successive iterations is less than 1.e-6. MATLAB functions that may prove useful include factorial() and abs().
i can't get it to work and i'm not sure what I am doing wrong.It's not going through the loop or anything
The Attempt at a Solution
%calculate cos(x) through a series
%user call seriesCos(x,n)
%x is number to evaluate n is desire cycles through series
x=input ('Enter x to be evalute: ');