I'm Using this approximaion:
$$e^x\approx \text{myFunc}(x)=\sum_{i=0}^{10}\frac{x^i}{i!}$$
I'm trying to write a function program to evaluate $e^x$ and have an error that is $\leq$ $10^{-7}$
which is the taylor approximation for $e^x$ up to 10. Is this the correct way to do it? This is a written assignment so I don't have MATLAB confirm if I am doing it correctly over the weekend and feel as though I am missing something. This is what I have, thanks for any and all help.
function px=taylorapprox_my(x,n)
% Input variables:
% x: the value of the interval
% n: the degree of the expansion
% Output:
% px: the value of P(x)
% Evaluate the Taylor approximation at each point n, in the interval [-1,1] up to degree 10, with n the degree of the polynomial.
for n=0:10
px=((x.^n)/factorial(n));
end
end