clear all
close all

% Annuity
% a_{n+1} = 1.01a_n - 1000.
% a_0 = 50000

b = -1000;
r = 1.01;

% Solution formula:
% a_k = r^k c + b/(1-r)
a(1) = 50000;

c = a(1) - b/(1-r);

k=24;

a_k = r^k*c + b/(1-r);

for k=1:24
   a(k) =  r^k*c + b/(1-r);
end

plot(a,'x','linewidth',2)

return
%%

% Equilibrium: a= b/(1-r) = -1000/(1-1.01)
a = b/(1-r);

a(1) = a;

c = a(1) - b/(1-r);

k=24;

a_k = r^k*c + b/(1-r);

for k=1:24
   a(k) =  r^k*c + b/(1-r);
end

plot(a,'x','linewidth',2)