The annual version of the compound interest formula A_{t} = A_{0} (1 + r)^{t} can have 2A_{0} substituted for A_{t} (because the amount doubles) and then solved for t as follows:

2 = (1 + r)

ln(2) = t ln(1+r)

t =

If the interest is, say 6%, this yields 11.89, which, since the question specifies annual interest, must be rounded to 12 years. Note that any growth factor A_{t}/A_{0} could be substituted for the number 2 in this discussion. Modula-2 code would be:

time := ( ln ( Amount / Principal ) / ln ( 1 + rate ) )

What is the effective annual rate for interest that is compounded more often than annually?

The idea here is that compounding more than annually produces a slightly higher rate of interest than if it were annual. Since many jurisdictions require a lender to report the rate as an annual one, an adjustment must be made.

Thenominal interest rateis the rate that is divided by the number of annual compounding periods to obtain the rate per period. Theeffective annual interest rateis the rate that would be applied annually to produce the same result as the nominal rate.

For instance $1000 at a nominal 10% for one year compounded each six months yields (100 * .05) = $50, and then (1050 * .05) = $52.50 or 102.50 altogether. Clearly the effective annual rate is 10.25%.

In general, if the nominal rate is *i*, the number of compounding periods is *n*, and the effective rate is *r*, for the two to yield an equivalent amount in t years

A_{0} (1 + r)^{t} = A_{0}

Multiplying both sides by 1/A_{0} and then taking t^{th} roots yields

(1 + r) =

or

r = - 1

Thus, if the investment (or loan) is of 10% compounded monthly, we would have

r = -1

= .1047 or 10.47% for the effective rate.These new formulas, along with several others discussed in section 4.9 can be collected into a library, say, with the following definition:

DEFINITIONMODULEFinanceMath;PROCEDURESimpleInterest (principal, rate:REAL; time:CARDINAL) :REAL; (* Pre: none Post: computes interest= principal * rate * time *)PROCEDURECompoundAmountA (principal, rate:REAL; time:CARDINAL) :REAL; (* Pre: none Post: computes A = principal (1 + rate)^time *)PROCEDURECompoundAmount (principal, rate:REAL; time, numberPerYear:CARDINAL) :REAL; (* Pre: numberPerYear # 0 Post: computes A = principal (1 + rate/numberPerYear)^(time * numberPerYear) *)PROCEDUREEffectiveRate (nominalRate:REAL; numberPerYear:CARDINAL) :REAL; (* Pre: numberPerYear # 0 Post: computes r = (1 + nominalrate/numberPerYear)^numberPerYear - 1 *)PROCEDURESCInterestFactor (interestPerPeriod:REAL; numberOfPeriods:CARDINAL) :REAL; (* Pre: interestPerPeriod # 0 Post: computes the series compound interest factor ((1 + i)^n - 1) *)PROCEDUREFutureValue (payment, interestPerPeriod:REAL; numberOfPeriods:CARDINAL) :REAL; (* Pre: interestPerPeriod # 0 Post: computes the future value of a payment by the formula payment * SCInterestFactor *)PROCEDURESinkingFundFactor (interestPerPeriod:REAL; numberOfPeriods:CARDINAL) :REAL; (* Pre: interestPerPeriod # 0 Post: computes the sinking fund factor, which is the reciprocal of the series compound interest factor *)PROCEDUREAnnuitySize (amount, interestPerPeriod:REAL; numberOfPeriods:CARDINAL) :REAL; (* Pre: interestPerPeriod # 0 Post: computes the size of an annuity or payment for a total amount by the formula AnnuitySize = R = Amount * SinkingFundFactor *)PROCEDUREPWorthFactor (interestPerPeriod:REAL; numberOfPeriods:CARDINAL) :REAL; (* Pre: interestPerPeriod # 0 Post: Computes the series presentworthfactor as (1 - (1 + i)^-n)/i *)PROCEDUREPresentWorth (payment, interestPerPeriod:REAL; numberOfPeriods:CARDINAL):REAL; (* Pre: interestPerPeriod # 0 Post: Computes the present worth, which is the payment times present worth factor *)PROCEDURECRFactor (interestPerPeriod:REAL; numberOfPeriods:CARDINAL) :REAL; (* Pre: interestPerPeriod # 0 Post: Computes the capital recovery factor, which is the reciprocal of the series present worth factor *)PROCEDUREAmortizePayment (amount, interestPerPeriod:REAL; numberOfPeriods:CARDINAL) :REAL; (* Pre: interestPerPeriod # 0 Post: Computes the payment to amortize an amount as amount * CRFactor *)ENDFinanceMath.

Implementation and testing of this library module is left as an exercise for the student.