How to create a program to calculate taylor series of e^x using a while loop?
Afficher commentaires plus anciens
I need to create a program to complete the function and then calculate percent error
1 commentaire
Steven Lord
le 19 Oct 2017
If you show us what you've written so far and describe where you're having difficulty we may be able to offer suggestions.
Réponses (1)
% 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
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!