The Museum of HP Calculators

HP Forum Archive 14

[ Return to Index | Top of Index ]

Accurate TVM for HP42S
Message #1 Posted by Tommi on 23 Jan 2005, 10:10 a.m.

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
Solve equation:
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:
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:

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 ;)
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"
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 

Edited: 23 Jan 2005, 12:13 p.m.

Re: Accurate TVM for HP42S
Message #2 Posted by hugh steers on 23 Jan 2005, 3:09 p.m.,
in response to message #1 by Tommi

hi tommi,

yes indeed. that is a good way to tackle the problem. i wrote a page on this problem (also with the same test case)

there's some stuff about how to fix it when you dont have the ln1 and exp1 functions (see the 15c case). also solving for `i' is interesting. checkout the references at the end too.


Re: Accurate TVM for HP42S
Message #3 Posted by Tommi on 23 Jan 2005, 4:10 p.m.,
in response to message #2 by hugh steers

Yes, the second test case is well-known. Also known as "A Penny for your Thoughts", see Mathematics Written in Sand
The first test case is from Hewlett-Packard Journal, October 1977.

In fact, while lnx+1 and e^x-1 are useful indeed, even better would be the super accurate
found in many HP financial calculators. At least in HP-37E, n can also be fractional, while HP-12C only works with INT(n), of much less use. Don't know how other HP financial calculators behave in this respect.


Edited: 23 Jan 2005, 5:02 p.m.

[ Return to Index | Top of Index ]

Go back to the main exhibit hall