% annuity.m % % A = annuity (amount curently in account) % P = payment per deposit period % r = interest rate per period % n = number of deposit periods % % Find the minimum interest rate assuming monthly compounding % given the desired annuity amount A at the end of n monthly % periods with given payment per period. % % The equation used is called the annuity due equation format long A = 75000; P = 150.0; n = 20 * 12; % Annuity due scalar function f = @(r) (P/r)*( (1+r)^n - 1) - A; % Find interval on which function changes sign % by plotting f(r) fplot(f, [0.001, 0.009]) grid on % this gives the interval [a.b] a = 0.005 b = 0.006 root = fzero(f,[a,b]) annualRateInPercent = (12 * root) * 100 % Try it using bisect root = bisect(f, a, b, 1E-10, 30, true)