HP 9 G Program Example: TVM Solve

Here is the problem: A bank retains a legal consultant whose thoughts are so valuable that she is paid for them at the rate of a penny per second, day and night. lest the sound of the pennies dropping distract her, they are deposited into her account to accrete with interest at the rate of 10% per annum compounded every second. how much will have accumulated after a year of 365 days?

We have the following formulas:

n = 60*60*24*365 = 31,536,000

i = 0.10 / N = 3.1709792e-9

pv = 0

pmt = -0.01

fv = ?

Using the textbook formula…

fv= -pmt*((1+i)^n-1) / i (when pv=0)

Therefore we have:

60*60*24*365->n

.1 / n->i

.01*((1+i)^n-1) / i

gives 331.6670067e3

meaning fv = $331,667.0067

Same problem backwards to obtain i

n = 60*60*24*365 = 31,536,000

i = ?

pv = 0

pmt = -0.01

fv = 331667.0067

For this we have to build a program:

prog 0 is to be the solver, thus:

INPUT L,H,E;

E=10^(-E)

X=L

GOSUB PROG 9;

A=Y

Lbl 1:

IF (ABS(H-L) < E*ABS(H)) THEN { GOTO 2; }

X=H

GOSUB PROG 9;

B=Y

C=H-B*(H-L) / (B-A)

L=H

A=B

H=C

GOTO 1;

Lbl 2:

X=C

END

it prompts for three inputs, L, H & E, L is lower bound for the answer, H an upper bound and E is the number of significant figures required (eg 8). This program expects a subroutine in prog9 which takes the value of X and computes the Y=F(X), Prog0 then solves for X, where Y=0.

For this problem, write prog9 as follows:

Y=((1+X)^31536000-1)*.01 / X

Y=Y-331667.0067

END

run prog0 and supply L=1e-30, H=1e-7, E=8. because our prog9 divides by X we can’t supply L=0. after only 5 seconds the program finishes. it doesnt print out the answer, you have to change back to main mode and examine the x register. and we get,

x=3.1709792e-9 which is correct.