how can i evaluate e^x using maclaurin expansion?

5 vues (au cours des 30 derniers jours)
Constandinos
Constandinos le 30 Oct 2014
I already have the factorial function

Réponses (1)

Torsten
Torsten le 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.

Catégories

En savoir plus sur Random Number Generation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by