HP Forums
(12C) Actuarial Calculations - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (12C) Actuarial Calculations (/thread-10730.html)



(12C) Actuarial Calculations - Gamo - 05-12-2018 05:41 AM

Since HP 12C always calculate [n] as an Integer with rounding up result.
Program below help solve this problem to get result with fractional part and [n] can be input with fractional part by using the Actuarial Method.

*Program to calculate [i] and use fractional [n]
Code:

01  ,
02  0
03  1
04 STO 3
05  1
06 RCL 3
07  1
08  +
09 STO 1
10 RCL [n]
11 CHS
12 Y^X
13 STO 2
14  -
15 RCL 3
16  ÷
17 RCL 3
18 RCL 0
19  x
20  1
21  +
22  x
23 RCL [PMT]
24  x
25 RCL [PV]
26  +
27 RCL [FV]
28 RCL 2
29  x
30  +
31 RCL 2
32 RCL 1
33  ÷
34 RCL [n]
35  x
36 STO 4
37  1
38 RCL 2
39  -
40 RCL 3
41  ÷
42  -
43 RCL [PMT]
44 RCL 3
45  ÷
46  x
47 RCL [FV]
48 RCL 4
49  x
50  -
51  ÷
52 STO-3
53 ENTER
54 CHS
55 X≤Y
56 X<>Y
57 EEX
58 CHS
59  8
60 X≤Y
61 GTO 05
62 RCL 3
63 EEX
64  2
65  x
66 ENTER
67 STO [i]

Example of calculating interest rate required for growth:
A savings account has a balance of $1000. What annual interest rate is required to double the money in 5½ years?

Store 0 in register 0 for END mode; store 1 in register 0 for BEGIN mode.

0 STO 0 > 0 // Set END mode
1000 CHS [PV] > -1000.00
2000 [FV] > 2000.00
5.5 [n] > 5.50
0 [PM]T > 0.00
R/S > 13.43 // Answer

*Program to calculate [n]
Code:

01  1
02 RCL [i]
03  %
04 STO 2
05  +
06 STO 1
07 RCL 0
08 Y^X
09 RCL [PMT]
10  x
11 STO 3
12 RCL [FV]
13 RCL 2
14  x
15  -
16 RCL [PV]
17 RCL 2
18  x
19 RCL 3
20  +
21  ÷
22  LN
23 RCL 1
24  LN
25  ÷
26 STO [n]

Example of calculating compound interest:
A deposit of $150 is made each month in an account paying 6.5 percent, compounding monthly. How long will it take to accumulate $20,000? Assume END mode.

Store 0 in register 0 for END mode; store 1 in register 0 for BEGIN mode.

0 [STO] 0 > 0.00
6.5 g [i] > 0.54
0 [PV]
150 [CHS] [PMT] > -150.00
20000 [FV] > 20000.00
[R/S] > 100.63

This program is from HP Support website.
https://support.hp.com/us-en/document/bpia5043

Remark:
All calculations above work on HP 15C using TVM program from the Advance Functions Handbook.
For HP-12C these two program together use about 95 steps this can enhance 12C TVM functions.

Gamo


RE: (12C) Actuarial Calculations - Dieter - 05-12-2018 07:00 PM

(05-12-2018 05:41 AM)Gamo Wrote:  *Program to calculate [i] and use fractional [n]

This seems to be a Newton-style solver that calculates the interest rate iteratively. This requires the usual convergence check: exit if the absolute value of the last change in i is less than 1E–8. Now take a look at line 53...56: here the HP programmer found a nice way to determine the absolute value of x.

Code:
53 ENTER
54 CHS
55 X≤Y
56 X<>Y

Compared with the common method (calculate √x²) this has three advantages: there are no roundoff errors, LastX is preserved and it also works for x ≥ 1E+50.

(05-12-2018 05:41 AM)Gamo Wrote:  Remark:
All calculations above work on HP 15C using TVM program from the Advance Functions Handbook.

Just to be clear – I assume what you want to say is this:

Unlike the 12C, the TVM program in the 15C Advanced Functions Handbook does not round n to the next higher integer, it directly returns a fractional results if required. So the above programs are not needed there.

Dieter


RE: (12C) Actuarial Calculations - Joe_H - 06-11-2019 02:40 PM

(05-12-2018 05:41 AM)Gamo Wrote:  Since HP 12C always calculate [n] as an Integer with rounding up result.
Program below help solve this problem to get result with fractional part and [n] can be input with fractional part by using the Actuarial Method.

*Program to calculate [i] and use fractional [n]

Gamo

As far as I can make out the HP12C does use non-integer n for i calculation. The only difficulty is calculating a non-integer n. I tried it on mine and got the correct i value for a non-integer n.

For example:
PV = -100
FV = 111.10 (PMT=0)
n = 1.1
i calculates as 10% which is correct

But:
PV = -100
FV = 111.10 (PMT=0)
i = 10%
n calculates as 2 which is the problem.

The TI BAII Plus (other permitted CFA calculator) does calculate n correctly for these TVM inputs.

As far as I can make out the first program (and longer one) isn't required but the second one is useful and I'll try it now.

Joe


RE: (12C) Actuarial Calculations - Joe_H - 06-11-2019 02:50 PM

Thanks Gamo,

That works fine (I'll probably change the registers where the interim values are stored so as not to affect a cashflow already in the calculator). The n value before calling the program needs to be lower than the calculated value or it overflows. Setting it to zero is the best bet before calling the program.

Joe