In: Computer Science
If S = 1-x/1! + x^2/2! - x^3/3! + .....
where n! means factorial(n) and x is a variable that will be
assigned.
Use matlab to compute S for x = 7 and n (number of terms) =
5. Write the value below as the one displayed when you
issue "format short" in matlab. Explain the process and result of
the question.
Matlab code
=====================================================================================
clc
x=7;
n=0;
S=0;
while n<5
temp = ((-x)^n)/factorial(n);
S=S+temp;
n=n+1;
end
format short
S
=====================================================================================
Output