clear all
clc
format long

syms x

prompt = 'Function: ';
f = input(prompt);
prompt = 'Expansion Point: ';
a = input(prompt);
prompt = 'Value: ';
v = input(prompt);
prompt = 'Error: ';
r = input(prompt);

z = 1:1000;
i = 2;
z(1) = subs(taylor(f, x, 'ExpansionPoint', a,'Order',1),x,vpa(v));
erro = 10000;
X = sprintf('\nTerm :%d | Value: %0.10f | Erro: %0.10f',1,z(1),erro);
disp(X)

while erro > r
    taylor1 = taylor(f, x, 'ExpansionPoint', a,'Order',i);
    z(i) = subs(taylor1,x,vpa(v));
    erro = abs(z(i)-z(i-1));
    X = sprintf('Term :%d | Value: %0.10f | Erro: %0.10f',i,z(i),erro);
    disp(X)
    i=i+1;
end



