Using compound interest, if an amount
is invested at an annual interest
and compounded
times per year then the amount
at the end of one year is
It’s not hard to show that the larger the value of
, the larger the amount at the end of the year. Assume that
= 100 and the interest rate is 1% so
= 0.01. Also assume there are 365 days in a year. Using MATLAB calculate
for the following cases:
(a) compounding every hour (so,
= 365 ∗ 24),
(b) compounding every second,
(c) compounding every millisecond,
(d) compounding every nanosecond,
(e) compounding every picosecond.
(f) You should find that the values computed in (d) and (e) are incorrect. The question is why, that is, what causes the floating-point calculation to produce an incorrect value? Based on this, given a value of
(with 0
<>
would you expect an incorrect result to be computed by MATLAB?