Post Reply 
(42S) TVM Program for HP 42S
05-23-2014, 11:02 AM (This post was last modified: 06-15-2017 01:29 PM by Gene.)
Post: #1
(42S) TVM Program for HP 42S

.pdf  TVM.pdf (Size: 49.74 KB / Downloads: 95) A TVM program for HP 42S.


Attached File(s)
.doc  TVM.doc (Size: 799 bytes / Downloads: 38)
Find all posts by this user
Quote this message in a reply
05-25-2014, 03:10 PM (This post was last modified: 05-27-2014 10:24 AM by Jeff_Kearns.)
Post: #2
RE: TVM Program for HP 42S
(05-23-2014 11:02 AM)Ender Wrote:  A TVM program for HP 42S.

There is a much shorter (albeit less extravagant) 31 step version here for those who don't wish to enter 253 lines of code:

An accurate TVM equation written as a program for the HP42S Solver.
n number of periods
i interest rate
PMT periodic payment
PV present value
FV future value
B/E BEGIN/END
Solve equation:
PMT*(i1-1)*(1/i+p)+PV*i1+FV=0

where (i1-1) = e1^(n*ln1(i))
and i1 = e^(n*ln1(i))
and ln1(x) = ln(1+x)
and e1(x) = e^x-1
p=0 for END, p=1 for BEGIN

The use of ln1+x and e^x-1 prevents the loss of significant digits for small values of i. Consider these extreme examples for accuracy checking:
Example 1:
n=63
i=0.00000161
PV=0
PMT=-1,000,000
END Mode (set B/E=0 in Solver)
Solving for FV:
HP 42S: 63,000,031.4434 (correct is 63,000,031.4433)
Example 2:

n=31536000
i=10/n
PV=0
PMT=-0.01
END Mode
Solving for FV:
HP 42S: 331,667.006689 (correct is 331,667.006691)

You might compare these results using the "normal" TVM equation, found in many manuals Wink
E.g. using the TVM equation in the 42S manual, we get
62,921,744.4422 and 311,565.594018 respectively.

The program:
00 {91-Byte Prgm }
01 LBL "TVM"
02 MVAR "N"
03 MVAR "I%"
04 MVAR "PV"
05 MVAR "PMT"
06 MVAR "FV"
07 MVAR "B/E"
08 RCL "I%"
09 100
10 /
11 LN1+X
12 RCL* "N"
13 E^X-1
14 RCL* "PMT"
15 RCL "I%"
16 100
17 /
18 1/X
19 RCL+ "B/E"
20 *
21 RCL "PV"
22 RCL "I%"
23 100
24 /
25 LN1+X
26 RCL* "N"
27 E^X
28 *
29 +
30 RCL+ "FV"
31 END
Find all posts by this user
Quote this message in a reply
05-25-2014, 07:34 PM
Post: #3
RE: TVM Program for HP 42S
This is my version.
Shorter, and also works for I%=0:

Code:
00 { 78-Byte Prgm }
01*LBL "TVM"
02 MVAR "N"
03 MVAR "i%"
04 MVAR "PV"
05 MVAR "PMT"
06 MVAR "FV"
07 MVAR "BEG"
08 RCL "i%"
09 X=0?
10 1 E-99
11 1
12 X<>Y
13 %
14 ENTER
15 LN1+X
16 RCL* "N"
17 E^X-1
18 STO+ ST Z
19 RCL* "PMT"
20 X<>Y
21 1/X
22 RCL+ "BEG"
23 *
24 X<>Y
25 RCL* "PV"
26 +
27 RCL+ "FV"
28 END

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)