Skip to content

Instantly share code, notes, and snippets.

@mrandri19
Created May 16, 2018 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrandri19/4032241badc8d1fcec39405058d9e3fd to your computer and use it in GitHub Desktop.
Save mrandri19/4032241badc8d1fcec39405058d9e3fd to your computer and use it in GitHub Desktop.
Esercitazione 0 Es 8
clearvars;
x = 1;
y = exp(x);
tol = 1e-10;
deg = 0;
[h, member] = tay(x,deg);
error = [];
while member > tol
deg = deg + 1;
[h, member] = tay(x,deg);
plot([x], [y], 'bo', [x], [h], 'ro');
error = [error; y-h];
end
format long;
error
format short;
function [y, member] = tay(x,n)
y = 1;
member = 1;
for i = 1:n
member = ((x.^i)./factorial(i));
y = y + member;
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment