how can i evaluate e^x using maclaurin expansion?

2 views (last 30 days)
I already have the factorial function

Answers (1)

Torsten
Torsten on 30 Oct 2014
Don't use factorials explicitly ; define the terms of the Taylor series recursively:
x=2;
n=10;
y=1;
summe=y;
for i=1:n
y=y*x/i;
summe=summe+y;
end
The variable 'summe' will contain an approximation to exp(x).
Now try to include an estimate for n such that
abs(sum_{i=0}^{n} x^i/i! - exp(x)) < eps
for a prescribed accuracy eps > 0.
Best wishes
Torsten.

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!