how can i evaluate e^x using maclaurin expansion?
2 views (last 30 days)
Show older comments
I already have the factorial function
0 Comments
Answers (1)
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.
0 Comments
See Also
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!