this is my version
(define (extra-interest principle-amount-invested interest-rate number-of-years) (- profit-compound-interest annual-interest)) (define annual-interest (* principle-amount-invested (expt (+ 1 interest-rate) number-of-years))) (define compound-interest (* principle-amount-invested (expt (+ 1 (/ interest-rate times-interest-compound))(* times-interest-compound number-of-years))) ) (define profit-compound-interest (- compound-interest principle-amount-invested))
thi is the question itself:
Most people realize that interest compounded monthly is more profitable than interest
accrued annually on an investment. For example, if you have an annual interest rate of 12%
on $1000 investment and you get paid interest once a year, then after one year you would
have $1120. However, if you were paid 1% each month, after the first month you would have
$1010 and you would be earning interest on more money for the second month. After the
second month, you would have $1020.10. After 12 months you would have approximately
$1126.83. This means that by using monthly interest rather than annual interest you
increased the output of your investment by approximately $6.83 over one year.
The formula to calculate the future value of an investment where interest is accrued
annually is: P(1 + r)t, where P is the principle amount invested, r is the interest rate (a
number normally between 0 and 1), and t is the number of years of the investment. A
formula to calculate compound interest is: P(1 + r/n)nt, where P is the principle, r is the
annual interest rate, n is the number of times that interest is compounded each year, and t is
the number of years of the investment.
Write a function called extra-interest that consumes the principle amount invested (a
non‐negative number), the annual interest rate (a non‐negative number), and the number of
years of the investment (a non‐negative integer), and produces the difference between the
profit earned using interest compounded monthly (12 times a year) and interest accrued
annually. For example, (extra-interest 1000 0.12 1) produces
6.825030131969720661201. Note that your function does not need to round off the result to
the nearest penny. However, you may use check-within with a tolerance of 0.00001 for
testing purposes. The built‐in Scheme function expt may be useful.
Edited by macosxnerd101: Added code tags and moved to Functional Programming.