how can i evaluate e^x using maclaurin expansion?

5 visualizaciones (últimos 30 días)
Constandinos
Constandinos el 30 de Oct. de 2014
Respondida: Torsten el 30 de Oct. de 2014
I already have the factorial function

Respuestas (1)

Torsten
Torsten el 30 de Oct. de 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.

Categorías

Más información sobre Random Number Generation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by