# Compounding, Discounting, Interest Rates

load(draw)$  set_draw_defaults(line_width=2, grid = [2,2], point_type = filled_circle,
          head_type = 'nofilled, head_angle = 20, head_length = 0.5,
             background_color = light_gray,  draw_realpart=false)$     
 fpprintprec : 5$  ratprint : false$

load ("Econ1.mac");

## Preface

In Dowling08.wxmx  we discuss some of the topics and work some of the problems in 
Ch. 8, "Exponential and Logarithmic Functions", from the text: Introduction to 
Mathematical Economics, 3rd ed., Edward T. Dowling, Schaum's Outline Series, 
McGraw-Hill, 2012.

This text is a bargain, with many complete problems worked out in detail. You should 
compare Dowling's solutions, worked out "by hand", with what we do using Maxima here.

A code file Econ1.mac is available in the same section (of Economic Analysis with Maxima),
which defines some Maxima functions used in this worksheet. Use load ("Econ1.mac");

This worksheet is one of a number of wxMaxima files available in the section
    Economic Analysis with Maxima
on my CSULB webpage.

Edwin L. (Ted) Woollett
https://home.csulb.edu/~woollett/
May 10, 2022

## References

Fundamental Methods of Mathematical Economics, Alpha C. Chiang and Kevin 
Wainwright, 4th ed., 2005, McGraw-Hill

Online Maxima html manual:
https://maxima.sourceforge.io/docs/manual/
                                           maxima_singlepage.html#Function-and-Variable-Index

## Basic and Natural Exponential Functions

Quoting Chiang and Wainwright, p. 256:

"In its simple version, the exponential function may be represented in the form:
    y = f(t) = b^t  (b > 1)      [10.1]

where y and t are the dependent and independent variables, respectively, and b denotes 
a fixed "base" of the exponent. The domain of such a function is the set of all real 
numbers," 

So t could be equal to 1/2, for example, and if b is allowed to be negative, we would be 
taking the square root of a negative number. So it is easier to restrict b to non-negative 
numbers. 

The restriction b > 1 differs from the restriction b > 0 only in the further exclusion of the  
cases of (1) 0 < b < 1, and (2) b = 1.

In the first case, consider b = 1/5, which leads to
            y = (1/5)^t = 1/5^t = 5^(-t),
so a function with a fractional base (like b = 1/5) can easily be rewritten into one with a 
base greater than 1 (such as 5 above). So the first case can be subsumed under the 
restriction b > 1. We see from this example that (1/5)^t is a decreasing function of t, 
since it is equivalent to 5^(-t).

As for the second case, using b = 1 gives
           y = 1^(t) = 1

1^(1/3);

1^(- 7/3);

1^(1.3);

so this particular exponential function "degenerates into a constant function, and may thus
be disqualified as a member of the exponential family."

### Graphical Form

For b > 1, b^t is an increasing function of t. To show a typical plot of such a simple 
exponential function, let's take the example b = 2 as the base. 

We also show (in purple) the function e^t, in which e is Euler's irrational number, 
approximately 2.718, for which Maxima has either %e or exp(1) as a correct syntax.

Euler's number is the base that is used predominantly for an exponential function because 
the derivative of e^x is just e^x. e^x is called the "natural exponential function".

float ([ %e, exp(1) ]);

[diff (%e^x, x), diff (exp(x), x) ];

diff (2^x, x);

diff (a^x, x);

at (%, a = %e);

wxdraw2d (xlabel = "t",  line_width = 2, key_pos = top_left, 
    key = " y = 2^t",explicit (2^t, t, -4, 5), 
    color = red, key = "dy/dt = log(2) 2^t", explicit (log(2)*2^t, t, -4, 5), 
    color =  purple, key = "y = e^t", explicit (%e^t, t, -4, 5),       
    color = black, key = "", line_width = 1, parametric (0, t, t, 0, 2^5));

### Common and Natural Logarithms

From this plot, we see that y = 2^t is continuous and smooth everywhere, infinitely 
differentiable, strictly increasing, and y increases at an increasing rate.

Using the basic properties of ln and exp, a^t = exp (ln (a^t)) = exp(t ln(a) ), 
so d (a^t)/dt = exp(t ln(a) * d( t*ln(a) )/dt = ln(a) * a^t.

diff (2^t, t);

Maxima's log(a) stands for the natural logarithm ln(a), with the properties
        (1)   ln (e^x) = x,     (2)   e^(ln(x)) = x.

exp (x) represents "the exponential function". Instances of exp (x) in input are 
simplified to %e^x;

%e represents the base of the natural logarithm, also known as Euler’s number. 
An approximate numeric value (with 16 digit accuracy) of %e is 2.718281828459045.

[ exp (x), %e^1];

fpprintprec;

fpprintprec : 0$
float (%e);
fpprintprec : 5$

[  log(exp(x)), log (%e^x) ];

[exp (log(x)), %e^(log(x)) ];

exp(1),numer;

[%^2, exp(2)], numer;

For small values of x, exp(x) can be approximated by a Taylor series expansion around the
point x = 0:

taylor (exp (x), x, 0, 3);

limit (exp (x), x, 0, plus);

As x approaches 0, exp(x) approaches 1, a pure number, so exp(x) has no dimensions, and
x must be dimensionless and be a "pure number", or the numerical part of a number which
has dimensions. If x has dimensions, then x + x^2/2 is mathematical nonsense. We can
rescue meaning by using exp(N[x]), where N[x] stands for the numerical part of x, a pure
number.

### The Meaning of Logarithm

Quoting Chiang/Wainwright (Sec. 10.3):
"When we have two numbers such as 4 and 16, which can be related to each other by the
equation  4² = 16, we define the "exponent" 2 to be the "logarithm" of 16 to the base of 4,
and write
   log_4 (16) = 2   (log of 16 to the base 4 equals 2).
It should be clear from this example that the logarithm is nothing but the "power" to which
a base (4) must be raised to attain a particular number (16)."

"In general, we may state that
       y = b^t  is mathematically equivalent to:  t = log_b (y)
which indicates that the log of y to the base b is the power to which the base b must be
raised in order to attain the value y. For this reason, it is correct, though tautological, to
write
           b^log_b(y) = y."

Maxima does not have a built-in function for the base 10 logarithm or other bases. For
practical work log10(x) := log(x) / log(10) is an useful definition.

## Exponential Equations

Suppose we want the value of x such that  a*b^x = c, Using the Maxima function solve,

solve(a*b^x = c, x);

The solution solve found comes from rearranging the equation as, first  b^x = c/a,
and then taking the natural logarithm of both sides, ln(b^x) = ln(c/a), and then using 
ln(b^x) = x ln(b), allowing one to solve for x.

## Plot of a Logarithmic Function t = ln(y)

wxdraw2d (xlabel = "y", ylabel = "t", key_pos = bottom_right,    
key = "t = ln(y)",    explicit (log (y), y, 0.1, 4) , color = black, line_width = 1,
  key = "",    explicit (0, y, 0.1, 4), parametric (1, yy, yy, log(0.1), log(4)))$

We see from this plot that log(y) is negative and increasing for y < 1, log(1) = 0, 
log(y) is positive and increasing for y > 1.

## Series Expansion of ln(1 + x)

The natural logarithm ln(x) is obtained in Maxima using log(x). ln(x) returns a 
dimensionless number (a pure number) always. The argument of ln(x) is x and must 
be dimensionless (a pure number).

ln(x) has the property ln(a^x) = x*ln(a). In this example, a^x must be dimensionless.

log(a^x);

grind(%)$

ln(x) also has the property ln( exp(A) ) = A. exp(A) is a dimensionless quantity, and the
argument A of the expression exp(A) must be dimensionless.

log (exp (A) );

ln(x) also has the property exp (ln(A) ) = A.

exp (log (A) );

A series expansion of ln(1 + x) useful for small values of x, is the Taylor series expansion
around x = 0, since ln(1) = 0.

log(1);

taylor (log (1 + x), x, 0, 3);

Clearly ln(1 + x) makes no mathematical sense if x has dimensions.

## Compounding, Discounting, Interest Rates

### Interest Compounding

### Annual Compounding

Loosely quoting Dowling, Ch. 8, Sec. 8.1
"Starting with a given principal P (t = 0), and given a decimal interest rate per year i > 0, if 
the value P (t = 0) is "compounded" annually for a given number of years t, the value
S at the end of t years is given by
         S = P (1 + i)^t
The "interest rate per compounding period" in this example is i, the "compounding period"
is one year, and the number of compounding periods is t.

### Multiple Compounding m times/year

If the principal P is compounded m times per year (evenly divided intervals) for t years, 
the number of compounding periods is m*t, the "interest rate per compounding period" 
is (i/m), the value S at the end of t years is given by
      S = P (1 + i/m)^(m*t)

### Dimensional Analysis of Annual Compounding Formula

Suppose x is not a "pure number", but has both a numerical value and dimensions.
Let [x] = dimensions of x and N[x] = the numerical value of x, without units.
Thus [ N[x] ] = 1, indicating N[x] is dimensionless.

Our annual compounding formula as written, FV = PV*(1 + i)^t, with t = number of years,
i the rate of interest per year, clearly makes no sense dimensionally.

First, [FV] = [PV], say dollars, so this requires [ (1 + i)^t ] = 1. In other words, because
FV and PV each have the same dimensions, the quantity (1 + i)^t should be dimensionless.

If i = 0.1/year, you cannot add that to 1, for example. Quantities can only be added if they
have the same dimensions. And raising (1+i), whatever that is, to the power 5 years, also
makes no sense.

The cure is to consider the annual compounding formula to be a special case of the 
multiple compounding formula, in which m = 1/year for example. Then (1 + i/m) becomes
(1 + (rate/year)/ (1/year) )  = (1 + N[i]). Likewise m*t becomes
(number of compounding/year)*(number of years) = (1/year)*(number of years) = N[t].

With this notation, annual compounding requires the form
       (1 + N[i])^N[t].

This is clearly harder to read quickly than the shorthand form (1 + i)^t, which we will use
despite its faults.

For example, with t = 1 yr, i = 0.1/yr (10% per year), m = 2/yr, in the formula
S = P*(1+i/m)^(m*t), i/m = (0.1/yr)/(2/yr) = 0.1/2 = 0.05, m*t = (2/yr)*1 yr = 2, 
S = P*(1 + 0.05)^2 = 1.1025*P.

### Continuous Compounding

If the principal P is compounded "continuously" at 100% interest (i = 1/yr) for one year, 
the limit as the number of compounding periods per year approaches infinity, and the
interest rate per compounding period (i/m) = (1/yr)/m simultaneously goes to zero, we 
use the previous formula in the limit m --> inf, with t = 1/yr. Let m = n/yr, with n an integer
with no units, then m*t = (n/yr)*(1 yr) = n, a pure number.
   S = limit(as n -> ∞) P*(1 + 1/n)^n

limit( (1 + 1/n)^n, n, inf);

float (%);

float (exp(1));

In summary, continous compounding of the principal P for one year at 100% interest per
year produces at the end of one year the amount S  = P*exp(1) ~ 2.72*P.

With continuous compounding at 10% per year for one year, i = 0.1/yr, t = 1 yr,

limit( (1 + 0.1/n)^n, n, inf);

float(%);

In summary, continuous compounding at 10% interest rate per year of the
principal P for one year produces the amount S = P*exp(0.1) ~ 1.105*P.

With continuous compounding at 10% per year for two years, i = 0.1/yr, t = 2 yr,
m*t = (n/yr)*(2 yr) = 2*n, a pure number. i/m = (0.1/yr)/(n/yr)  = 0.1/n = a pure number.

limit( (1 + 0.1/n)^(2*n), n, inf);

float(%);

exp(0.2);

Generalizing, continous compounding at decimal interest rate i per year for t years, let's use
r  replacing the symbol i for the decimal interest "rate" per year.

limit( (1 + r/n)^(n*t), n, inf);

In summary, given the decimal interest rate per year r, and the number of years t of
continuous compounding of the principal P, the amount accumulates to
      S = P*exp (r*t).

### Example 1, fv (rate, PV, nPeriods), fvm (rate, PV, m, nPeriods)

Find the value of $100 at 10% interest per year compounded for 2 years 1) annually,
2) semiannually, and 3) continuously.

ANNUAL COMPOUNDING

1) compounded annually:  FV = PV (1+ i)^t
Ignoring units, i = 0.1 is the rate of interest per compounding period (here: per year) and
 t = 2 is the number of compounding periods (here: the number of years), and PV = 100.

100*(1 + 0.1)^2;

The software file Econ1.mac has a function fv(rate,PV,nPeriods) which automates this 
future value (FV) calculation 

fv (0.1,100, 2);

grind ( fundef(fv) )$

SEMI-ANNUAL COMPOUNDING

2) compounded semi-annually: FV = PV (1 + (i/m))^(m*t).
In this example i = decimal interest rate per year = 0.1 (10%/yr), 
m = 2 compoundings per year, t = 2 years, m*t = 4, i/m = 0.1/2 = 0.05.

100*(1 + 0.1/2)^4;

fvm (0.1,100, 2, 2);

The software file Econ1.mac has a function 
       fvm (rate, PV, m, nPeriods) 
which automates this future value given m compoundings for each of n Pperiods. 
'rate'  is the decimal interest rate per period, rate/m is the decimal interest rate per 
each of the m multiple compounding periods.

grind ( fundef (fvm) )$

CONTINUOUS COMPOUNDING

3) compounded continuously: FV = PV exp(r*t).  Assuming r = 0.1 per year, t = 2 years,
r*t = (0.1/year)*(2 year) = 0.2.

100*exp(0.1*2);

### Prob. 8.23: Growth of Sales/yr, Annual Compounding

A firm with sales of S(0) = 150,000 per year expects sales per year to grow by 8% per year. 
Determine the  expected level of sales/yr after 6 years. 

With annual compounding for t = 6 years at an growth rate per year of 8% (i = 0.08).

S(t) = S(0)*(1 + i)^t, S(0) = 150000 = 1.5e5, i = 0.08, t = 6 years.

1.5e5*(1.08)^6;

Sales per year should equal 238,030 per year after six years.

fv (0.08, 1.5e5, 6);

### Sales Growth over 3 yr 7 mo, Monthly Compounding

For the previous problem, what is the expected level of sales/yr after 3 years 7 months
if we assume monthly compounding at the monthly rate 0.08/12?

First method is P*(1 + i/m)^(m*t), where i  = rate/yr = 0.08, m = 12/yr, t = 3 + 7/12 yr 
= 3.583 yr.

1.5e5*(1 + 0.08/12)^(12*(3+7/12));

The second method is to assume the compounding period is one month, the rate
per month = 0.08/12, the number of compounding periods is 36 + 7 = 43.
Use interest rate per month (8%/12) over 36 + 7 months. 

We can use fv (monthly rate, initial value, number of months):

fv (0.08/12, 1.5e5, 43);

which is the same answer. Sales/yr should equal 199,610/yr  after 3 years 7 months.

### Prob. 8.27,  Negative Growth Rate Example

A discount clothing store reduces prices by 10% each day until the goods are sold. What
will a $175 suit sell for in 5 days?

The discounting period is 1 day, or the compounding period is 1 day with a negative rate.

After one day,the price of the suit is 175*(1 - 0.1) = 0.9*175 = 157.5.
After two days, the price of the suit is 175*(1 - 0.1)*(1 - 0.1) = 0.9*157.5. etc.
After 5 days, the price of the suit will be 175*(1 - 0.1)^5 = 175*(0.9)^5.

175*(0.9)^5;

This problem is an example of a negative growth rate: rate/day = - 10% = -0.1, over 5 days.

fv ( - 0.1, 175, 5);

### Prob 8.28, Depreciation of the Value of a New Car

A new car depreciates in value by 3% per month for the first year. What is the book value
of a $60,000 car at the end of the first year?

With i = - 0.03 per compounding period, the compounding period is one month, m = 1,
t = 12 months.  FV(1year) = PV(t=0)*(1 + i)^t = 60000*(1 - 0.03)^12

6e4*(1 - 0.03)^12;

fv (- 0.03, 6e4, 12);

The book value at end of the first year is $41,631.

### Prob 8.29,  Depreciation of the Dollar

If a dollar depreciates at 2.6% per year, what will a dollar be worth in real terms 25 years
from now?

With i = -0.026 per year, the compounding period is one year, m = 1, t = 25 years.
FV(25 yr) = PV(t=0)*(1 + i)^t = 1*(1 - 0.026)^25

(1 - 2.6/100)^25;

In 25 years one dollar willl be worth 51.76 cents.

fv (- 0.026, 1, 25);

### Prob 8.31, Investment Growth, interest (PV, FV, nperiods)

A five (5) year development plan calls for boosting investment from 2.6 million per year
to 4.2 million per year. What average annual increase in investment is needed each year?

We start with the equation  
        4.2 = 2.6*(1 + i)^5.
To solve for the unknown decimal rate i, divide both sides by 2.6, raise both sides to 
the (1/5)'th  power, and subtract 1.

(4.2/2.6)^(1/5) - 1;

Roughly a 10.1% annual increase in investment per year is required.

interest (2.6, 4.2, 5);

In the software file Econ1.mac is a function: interest (PV, FV, nPeriods) which calculates
the decimal interest rate per compounding period, given PV, FV, and the number of 
compounding periods nPeriods.

grind (fundef (interest) )$

### Changing Rate and Number of Compounding Periods Each Yr.

This example is taken from
https://www.youtube.com/watch?v=hsvq75pl6-A

An account credits interest using a 9% interest rate compounded monthly for the first
year and an 8% discount rate compounded quarterly for the second year. Determine 
the accumulated value after two years of a deposit of $1000.

We show how to use multiple calls to the function fvm(rate, PV, m, nPeriods).
You should work this problem "by hand" to understand the logic.

fvm (0.08, fvm(0.09,1000,12,1), 4, 1);

Using fvm (rate, PV, m, n) for compounding m times each of n periods twice gives us the
final accumulated amount after two years: $1,184.

### No of Yrs to Increase to 10*PV,  nPeriod (rate, PV, FV)

Assuming $25,000 invested at 12% interest compounded annually, after how many years
will it have exceeded $250,000?

Assuming compounding once per year at interest rate i/yr,
    FV = PV*(1+i)^n.
Divide by PV and take the natural logarithm of both sides, then use ln(a^x) = x*ln(a) to get
  ln(FV/PV) = n*ln(1+i),  so
n = ln(FV/PV) / ln(1+i).

Computing n (in years):

log(10)/log(1.12), numer;

Since this is more than 20 years, how many weeks in the overage 0.32 years?

52*(weeks/year) *0.32*year;

The investment exceeds $250,000 after about 20 yr 17 wks, so in round numbers, wait
twenty one years to more than meet the target.

nPeriod (0.12, 2.5e4, 2.5e5);
nPeriod (0.12, 1, 10);

In the software file Econ1.mac is a function nPeriod (rate, PV, FV) which computes the
number of compounding periods nPeriod needed to achieve the final value FV, given
the initial value PV, and the interest rate per compounding period 'rate'.

As our derivation shows, the number of periods needed only depends on the ratio
FV/PV, which in our case is 10.

grind (fundef (nPeriod) )$

### Choosing a Bank for Investment

A principal of $10,000 is invested at one of the following banks:

a) at 4.75% interest, compounded annually 
b) at 4.7% interest, compounded semi-annually 
c) at 4.65% interest, compounded quarterly 
d) at 4.6% interest, compounded continuously

Which bank offers the best "deal"?

The accumulation of principal for one year (at each bank) will reveal the bank with the 
best deal.

We need to increase the number of significant digits from five to six
to see the differences.

fpprintprec : 6$

Bank (a): We use fv (i, PV, n) with i = 0.0475 per year, n = 1 year.

fv(0.0475, 1e4, 1);

Bank (b):  We use fvm (i, PV, m, n) with decimal interest rate per year i = 0.047 per year,  
number of compoundings per year m = 2 per year, number of years n = 1 year.

fvm (0.047, 1e4, 2, 1);

Bank (c): We use fvm (i, PV, m, n) with i = 0.0465 per year, m = 4 per year, n = 1 year.

fvm (0.0465, 1e4, 4, 1);

Bank (d): With continuous componding, we use PV*exp(r*t) with r = 0.046/yr, t = 1 yr.

1e4*exp (0.046);

Bank (b) offers the best return.

We return to our chosen default value of fpprintprec.

fpprintprec : 5$

### Effective vs. Nominal Rates of Interest

The effective rate of interest concept allows easy comparisons between alternative
compounding schemes.

As we saw in Ex. 1 above, a given principal set out at the same nominal rate of interest i
will earn different effective rates of interest, depending on the method of compounding.
If we let ie be the "effective rate of interest", for multiple compounding we find ie from 
the equation

    P*(1 + ie)^t = P*(1 + i/m)^(m*t).

Dividing both sides by P and raising each side to the (1/t) power yields the equation
   1 + ie = (1 + i/m)^m, 
Hence
   ie = (1 + i/m)^m - 1.

[i,m,t,ie];

solve( (1 + ie)^t = ( 1 + i/m)^(m*t), ie);

For continuous compounding, we find ie from the equation

  P*(1 + ie)^t  =  P*exp (r*t).

Again, dividing by P and raising both sides to the (1/t) power produces
  1 + ie = exp(r)
Hence
   ie = exp(r) -1.

solve ( (1 + ie)^t = exp (r*t), ie);

### Dowling Ex. 2, Effective Annual Rate of Interest

Find the effective annual rate of interest for a nominal interest rate of 10% when
1) compounded semi-annually
2)  continuously.

1) semi-annually:

ie : (1 + 0.1/2)^2 -1;

Thus for semi-annual compounding at 10%, ie = 10.25%.

2) continuously

ie : exp (0.1) -1;

Thus for continuous compounding at 10%, ie = 10.52%.

### Discounting, Discount Rate, pv (i, FV, t), pvm (i, FV, m, t)

Quoting loosely from Dowell, Ch. 8, Sec.3:
"A sum of money to be received in the future is not worth as much as an equivalent amount
of money in the present, because the money on hand can be lent at interest (invested) 
to grow to an even larger sum by the end of the year. If present market conditions will 
enable a person to earn 8% interest compounded annually, $100 will grow to $108 in 
one year; $100 in hand now is worth the same as $108 received a year from now."

FV = PV*(1+ i)^t, with PV = 100, i = 0.08/yr, t = 1 yr.

100*(1 + 0.08);

PV = FV/(1 + i)^t = FV*(1 + i)^(-t).

pv (0.08, 108, 1);

At 8% per year interest, $108 to be received one year in the future would be equal in
value to receiving $100 now.

"Discounting" is the process of determining the present value (PV) of a future sum of
money (FV). Under annual compounding,
  FV = PV*(1 + i)^t.
Solving for PV,
   PV = FV*(1 + i)^(-t) = FV/ (1+i)^t.

Similarly, under multiple compoundings
   PV = FV*(1 + i/m)^(- m*t).

Under continuous compounding
   PV = FV*exp (- r*t).

When finding the present value, the interest rate is called the "discount rate".

### Dowling, Ex. 3, Present Value of a 5 Yr. Bond

The present value (t = 0) of a 5-year bond with a face value of $1000 and no coupons is
calculated here, assuming comparable opportunities for investment profits offer 9% interest
under annual compounding.

Here the future value of the bond at t = 5 yr is $1000, and the discounted present value
is:

 1000*(1 + 0.09)^(-5);

Using pv (i, FV, t):

pv (0.09, 1000, 5);

Future value in 5 years of $649.93 at 9% interest per year (annual compounding) is

fv (0.09, %, 5);

Thus a bond with no coupons promising to pay $1000 five years from now is worth 
approximately $649.93 today, since $649.93 at 9% interest will grow to $1000 in 5 years.

### Discounting Over 3 yr 7 mo

Find the discounted value of $2800 due in 3 years 7 months if money is worth 10%/year.

Use interest rate per month  = 10%/12 over 36 + 7 months.

pv (0.1/12, 2800, 36+7);

fv (0.1/12, %, 36+7);

The present value (t = 0) of the $2800 due in 3 yr 7 mo is $1,959.66.

### Cash Now or Delayed Payment Options?

A person can buy a lot for $13,000 cash now.
The seller offers an alternative payment option: $6000 in cash now, another 
$6000 2 years from now, and another $6000 5 years from now. Which option, $13,000
now or the three payment plan  is better under the following two scenarios?

a) Money can be invested at 18% interest per year with monthly compounding;

b) Money can be invested at 12% interest per year with quarterly compounding for the
first 3 years and at 14% interest per year with quarterly compounding for the next 2 
years.

This problem assumes the buyer is willing and able to keep any cash on hand invested 
and earning interest until needed.

OPTION (a): 
Price of the lot (discounted to t = 0) for the three payments option (a):

fpprintprec : 7$

6000 + pv(0.18/12, 6000, 24) + pv(0.18/12, 6000, 60);

6000 + pvm(0.18,6000, 12, 2) + pvm(0.18, 6000, 12, 5);

The total (discounted to present value (t = 0)) price for the lot under option (a) 
is $12,653, less than the cash now option, so the three payment option (a) is better
 than $13,000 at t = 0.

OPTION (b): 
Price of the lot (discounted to t = 0) for the three payments option (b):

6000 + pv(0.12/4,6000,8) + pv(0.12/4, pv (0.14/4,6000,8), 12);

6000 + pvm (0.12,6000,4, 2) + pvm (0.12, pvm(0.14,6000,4,2), 4, 3);

Payments option (b) present value price for the lot is $13,932, which is greater than 
the cash option. The cash option is the better path if one is presented with the rates 
available with option (b).

fpprintprec : 5$

### Converting Exponential to Natural Exponential Functions

Expressions used to measure rates of discrete growth of principal (growth that takes
place only at discrete intervals of time such as the end of the year or every six months)
can be converted into a natural exponential function used to measure continuous growth
of principal. We need to relate the interest rate r in an expression exp(r*t) to i and m in
a discrete growth expression. 

Start with P(1 + i/m)^(m*t) = P*exp(r*t), cancel P on both sides, take the natual log of 
both
sides, use ln(e^x) = x, ln(a^x) = x*ln(a), to get
  (m*t)* ln (1 + i/m) = r*t, or

                       r = m*ln(1 + i/m)

or let Maxima's solve function do it:

solve ((1 + i/m)^(m*t) = exp(r*t), r);

grind(%)$

ln(1 + i/m) itself is a pure number (no dimensions) and r and m have the same dimensions.

The ratio i/m must be dimensionless in the above expression for r, as you can see from
the Taylor series expansion of ln(1 + x) about x = 0 for small values of x.

taylor (log (1 + x), x, 0, 3);

If x had non-zero dimensions, it would be impossible to add these terms.

Hence we can write the future value FV in terms of an exponential:

  FV = PV*(1 + i/m)^(m*t) = PV*exp ( m*ln(1 + i//m)*t )

### Example 4

A natural exponential function exp*r*t) can be used to determine the future value of $100 
at 10% interest compounded semi-annually for 2 years:
  FV = PV*exp(r*t), where    r = m*ln(1 + i/m), as we proved above.

In Ex. 4, t =  2  yrs, m = 2/yr, i = 0.1/yr, i/m = (0.1/yr) / (2/yr) = 0.1/2, the ln function is
dimensionless, so r has the same dimensions as m: 1/year.

r : 2*log (1  + 0.1/2);
100*exp (r*2);

which is the same future value found in part (2) of Ex. 1 using the formula
    FV =   100*(1 + 0.1/2)^4.

fvm (0.1, 100, 2, 2);

With natural exponential functions, the continuous growth is given by r in PV*exp(r*t).
Thus the continuous growth rate of $100 at 10% interest compounded semi-annually is
0.09758 or 9.758% per year. In other words, 9.758% interest with continuous compounding
is equivalent to 10% interest with semi-annual compounding.

The function rate (i,m), defined in Econ1.mac, can be used to find r:

rate (0.1, 2);

grind (fundef (rate))$

### Example 5

A small firm with current annual sales of $10,000/yr projects a 12% growth in sales per year.
The projected sales per year at the end of four years, calculated using an "ordinary 
exponential function" (not a natural exponential function exp(x))  is $15,735.

10000*(1+ 0.12)^4;

fv (0.12, 10000, 4);

### Example 6

The annual sales projection done in Ex. 5 is recalculated using a "natural exponential
function" with r = m*ln(1 + i/m) and m = 1/yr.

r : log (1 + 0.12);
 10000*exp (r*4);

## Estimating Growth Rates from Data Points

Suppose sales volume equals 2.74 million in 1996 and 4.19 million in 2001. Let t = 0 for
the base year 1996, then t = 1 is 1997, ..., t = 5 is 2001. Use the two data points (t,sales) 
given to define a formula for sales growth in the form: in terms of a natural exponential 
function in the form:
     S(t) = S(0)*exp (r*t).
At t = 0, we use exp(0) = 1, so 2.74 = S(0)*exp(0) = S(0).
At t = 5, we use 4.19  = S(0)*exp (r*5) = 2.74*exp(r*5).
So exp(r*5) = 4.19/2.74 = 1.529, => ln(exp(r*5)) = r*5 = ln(1.529) = 0.425,
r = 0.08495

So we can solve the last equation for r, using ln (exp(5*r)) = 5*r 
thus getting r = (1/5)*ln(4.19/2.74).

r : log (4.19/2.74) / 5;
S5 : 2.74*exp (r*5);

With r = 0.085, the rate of continuous growth per year is 8.5%. 
To find the rate of discrete growth, recall the formula r = m*ln (1 + i/m) and solve this for i
using exp( ln(A)) = A to find i = m* ( exp(r/m) -1 ).

For this example, m = 1, so

i : exp (r) -1;

The rate of discrete growth at annual compounding is ~ 8.9%.

kill(r,m,i)$
solve (r = m*log(1 + i/m), i);

grind(%)$

### Example 7

Given the two data points (t, Sales) above, we can use the data directly to find the discrete
interest rate i for annual compounding, as follows:
We use S(t) = S(0)*(1 + i)^t,  and (1 + i)^0 = 1.
S(0) = 2.74, 4.19 = 2.74*(1+i)^5, and solve for i to get

i : (4.19/2.74)^(1/5)  - 1;

which gives: The rate of discrete growth at annual compounding is ~ 8.9%.

### Prob. 8.9

Determine the interest rate needed to have money double in 10 years under annual
compounding.

Using FV = PV*(1 + i)^t, solve  2 = 1*(1 + i)^10  = (1+i)^10 ==> (1 + i) = 2^(1/10),
or:     i = 2^(1/10) -1.
Here are three ways to get a decimal value from this equation.

i : 2.0^(1/10) -1.0;

i : float (2^(1/10) -1);

i : 2^(1/10) -1, numer;

Under annual compounding money doubles in ten years with i = 7.18%

Finally, we can use interest (PV, FV, nperiods)

interest (1,2,10);

### Prob. 8.11

What interest rate is needed to have money treble in 10 years when compounded
 quarterly?

3 = 1*(1 + i/4)^40 ==>   1 + i/4 = 3^(1/40) ==> i/4 = 3^(1/40) - 1, so

i : 4* (3^(1/40)  - 1), numer;

You need i = 11.14% interest rate under this multiple compounding scenario.

Using interest (PV, FV, nperiods), with nperiods = 40 = 4*10, we get (i/m) = i/4 = 0.028.

interest(1,3,40);

Then we have to multiply both sides by 4 to uncover the interest rate per year (i):

4*%;