How to create a program to calculate taylor series of e^x using a while loop?

I need to create a program to complete the function and then calculate percent error

1 commentaire

If you show us what you've written so far and describe where you're having difficulty we may be able to offer suggestions.

Connectez-vous pour commenter.

Réponses (1)

pb
pb le 19 Oct 2017
Modifié(e) : pb le 19 Oct 2017
% calculation of e^x in taylor series
x=3; % took an exampke vale of x=3
n=10; % took an example value of n=10
i=1;
f=1;
while i<n || i==n
f= f+(x.^i)/factorial(i);
i=1+i;
end
f_o=exp(x);
y=(f_o-f)*100/f_o;
disp(['The error is ',num2str(y),'%'])
Hope this is useful

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Modifié(e) :

pb
le 19 Oct 2017

Community Treasure Hunt

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

Start Hunting!

Translated by