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 Comment

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

Sign in to comment.

Answers (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

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 19 Oct 2017

Edited:

pb
on 19 Oct 2017

Community Treasure Hunt

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

Start Hunting!