Using Matlab The compound interest formula describes the amo
Using Matlab
The compound interest formula describes the amount A that you will have after t years if you deposit an initial amount p in a bank that pays interest at the decimalized rate r per year, compounded n times per year.
Here is the formula
Following table shows a comparison of how much money you would have after a year if you received 6% interest on $1000, compounded in various ways.
The table suggests that the more frequently a bank compounds interest on your savings account, the better it is for you.\\
a) Plot two graphs: annual, daily over a period of 100 years. Make sure to provide legends for the graphs.
b) Now compute the final difference (after 100 years) and print it out also.
c) Using the annual compounding formula, now compare 5% vs. 1.25% over 30 years.
d) Make sure to plot the results and print out the final difference. Make sure to provide legends for the graphs.
| Compounding Method | n | Balance after one year |
| annually | 1 | 1060 |
| semiannually | 2 | 106?0.90 |
| quarterly | 4 | 106?1.36 |
| monthly | 12 | 106?1.68 |
| daily | 365 | 106?1.83 |
| hourly | 365 x 24 | 106?1.84 |
Solution
format short g
a=[];
d=[];
years=1:1:100;
for t = 1:100
a(t)=1000*(1+0.06)^t;
d(t)=1000*(1+(0.06/365))^(365*t);
end
plot(years, a, years, d, \'.-\'), legend(\'annualcompunding\', \'dailycompounding\'), xlabel(\'years\'), ylabel(\'amount in lakhs\'), title(\'annual compounding \'),
finaldifference=d(100)-a(100)
