load(draw)$ 
set_draw_defaults(draw_realpart=false)$
kill(all)$ fpprintprec:5$ ratprint:false$

# Time

This chapter considers two aspects of time. The first involves the analysis
of decisions whose effects have implications over time for costs or revenues.
The second involves processes that play out over time, in a dynamic fashion.

## Introduction

## Intertemporal Decisions

This section examines aspects of consumers' behavior and firms' behavior
when today's decisions have direct implications for the future. 

### Review

This section reviews basic relationships that provide a foundation for the
models that follow.

### The Interest Rate, Time, and Compounding

The analysis starts with the concept of compounding. An amount P has a rate
of return of r percent per period, and the earnings are compounded at the
end of some interval. In the first expression, the interval is the relevant
period (say year). In the second expression, the compounding occurs at an 
interval of 1/n periods. The third expression shows the implication of 
very rapid (in the limit, continuous or instantatenous) compounding.

[F1(P,r,t):=P*(1 + r)^t,
F2(P,r,n,t) := P*(1 + r/n)^(n*t),
limit(F2(P,r,n,t), n, inf)];

The graph below illustrates the difference that frequency of 
compounding can make.

matrix(["Annual","Biannual","Quarterly","Continuous"],
[F2(100,0.05,1,50),F2(100,0.05,2,50), F2(100,0.05,4,50), 
   100*exp(0.05*50)]);
wxdraw2d(xlabel = "Number of periods", ylabel="$",
 user_preamble="set key left",
 key="Annual",explicit(F1(100,.05,t), t, 0, 50),
 color=red,key="Semiannual",explicit(F2(100,.05,2,t),t,0,50),
 color=black, key="Quarterly",explicit(F2(100,.05,4, t), t,00,50),
 color=green,key="Instantaneous",explicit(100*exp(.05*t),t,0,50),
 dimensions=[540,720])$

Often future values are given and we wish to express these in terms
present values. This conversion, called discounting, can be period or 
instantaneous. The output below shows the discounting counterparts to 
the calculations of future values that appear above.

solnPV: [solve(F1(P, r, t)=FV, P), 
    solve(F2(P,r,n,t)=FV, P),solve(P*exp(r*t)=FV,P)];

These expression can be converted to functional expressions for use
in further analysis.

PV1(FV,r,t):=     ''(rhs(solnPV[1][1]))$
PVn(FV,r,n,t):=   ''(rhs(solnPV[2][1]))$
PVcont(FV,r,t):=  ''(rhs(solnPV[3][1]))$

The effects of the dicount period and the interest rate appear
below, when discounting is once per period. As exercises, replace
PV1( ) with PVn( ) and PVcont( ).

[PV1(1000,.01,100),PV1(1000,.05,100), PV1(1000,.10,100)];
wxdraw2d(yrange=[0,1000],xlabel="Number of periods",
 ylabel="$",line_width = 2,key="r = 0.02",
 explicit(PV1(1000,.02,t),t,1,100),
 color=red,key="r = 0.05", explicit(PV1(1000,.05,t),t,1,100),
 color=black,key="r = 0.10",explicit(PV1(1000,.10,t),t,1,100),
 dimensions=[640,640])$

### A Stream of Payments

The next cell extends the analysis to consider more than a single
payment to be received at various times in the future. The present
value of such a series is the sum of the present values of the components.

tlist: [1, 2, 3, 4]$  FVlist: [100, 125, 90, 150]$
PVlist: PV1(FVlist,0.05,tlist);
sum(PVlist[t],t,1,length(PVlist) );

An important special case is one in which the future receipts are 
equal and are received at the end of each of t periods. The present
value of such a series is the function created by the first command.

The second command evaluates this function for specified r and t values.
The next two commands establishes the equality of the caluculation
using th function and the calculation using a list of individual
present values.

PVSeqn(FV,r,t):= FV*(1 - (1+r)^-t)/r;
PVSeqn(100,0.05,4);
FVlist2: [100, 100, 100, 100];
PVlist2: PV1(FVlist2,0.05,tlist);
sum(PVlist2[t],t,1,length(PVlist2) );

The next graph shows the prsent value of flows with three different
r values and with t ranging from 0 to 50 periods.

wxdraw2d(user_preamble="set key top left", 
 xlabel="Number of periods, t",ylabel="Present Value, $", 
 key="r = 0.02",line_width=2,explicit(PVSeqn(100,.02,t),t,1,50),
 color=red,key="r = 0.05",explicit(PVSeqn(100,.05,t),t,1,50),
 color=black,key="r = 0.10",explicit(PVSeqn(100,.10,t),t,1,50))$

If the receipt stream is extended far enough into the future, then
the present value equals FV/r.

assume(r>0)$   limit(PVSeqn(FV, r, t), t, inf);