Week 3.5 - Deriving 4th order approximation of a 2nd order derivative using Taylor Table method
clear all
close all
clc
% number of terms in taylor series
n=38;
n_x=10
x=linspace(0,05,n_x);
%for each value of x
for j=1:n_x
%for each term in taylor series
for i=1:n
term(i)=x(j)^(i-1)/factorial(i-1);
end
taylor_series_approximation(j)=sum(term);
end
figure(1)
plot(x,exp(x),'Color','r')
hold on
plot(x,taylor_series_approximation,'*','Color','b')
xlabel('x axis')
ylabel('exp(x)')
legend('exact expresion','taylor series approx')