The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
HP-41 Internal Rate of Return (IRR)
11-03-2024, 08:02 AM (This post was last modified: 11-05-2024 01:51 PM by Ángel Martin.)
Post: #1
HP-41 Internal Rate of Return (IRR)
Calculation of IRR, Internal Rate of Return
i.e. interest rate for which the Net Present Value (NPV) is zero.

Here's a short FOCAL routine I've used as benchmark while working on a MCODE version of IRR soon to be released.

The routine prompts for the initial Capital investment C0, the number of periods N, and the first cash-flow C1. Based on C1 the remaining cash-flows are calculated using two options,

LBL "IRR+" for the aithmetic: Cn = C1+k*(n-1)
LBL "IRR*" for the geometric: Cn = C1* (1+k)^(n-1)

with k being the ratio also an input prompted by the program.

The program solves for IRR using SOLVE (or FROOT if you use the SandMath).
In his version the Initial guesses are hard-coded to be 0.1 and 0.5

Example: With C0=(250.000,00), C1 = 100.000,00, N=5
arithmetic, k=50.000,000 => IRR = 56.72%
geometric, k=0.05 (5%) => IRR = 32.50%

Code:
1   LBL "IRR+"    
2   CF 03    
3   GTO 03    
4   LBL "IRR*"    
5   SF 03    
6   LBL 03    
7   "N=?"    
8   PROMPT    
9   STO 01      N
10  "C0=?"    
11  PROMPT    
12  STO 04     C0
13  "C1=?"    
14  PROMPT    
15  STO 03     C1
16  "K=?"    
17  PROMPT    
18  STO 05     Cn factor
19  "I+*"     FName
20  0,1       a
21  ENTER^    
22  0,5       b
23  FROOT     do SOLVE
24  RTN    
25  LBL "I+*"    
26  STO 02     irr
27  CLX    
28  STO 06     reset sum
29  RCL 01     N
30   E3    
31   /         0.00N
32   E    
33  +          1,00N
34  STO 00     counter
35  LBL 00    
36  RCL 03     c1
37  RCL 05     k
38  RCL 00     n,00N
39  INT        n
40   E    
41  -          (n-1)
42  FS? 03    
43  GTO 03
44  *          k.(n-1)
45  +          Cn = C1+k.(n-1)
46  GTO 00    
47  LBL 03
48  ISG Y     k+1
49  NOP
49  Y^X        (k+1)^(n-1)
50  *          Cn = C1*(1+k)^(n-1)
51  LBL 00
52  RCL 02     irr
53   E    
54  +          1+irr
55  RCL 00     n,00N
56  INT        n
57  Y^X        (1+irr)^n
58  /          Cn/(1+irr)^n
59  ST+ 06     partial sum
60  ISG 00     increase counter
61  GTO 00     do next term
62  RCL 06     total SUM
63  RCL 04     C0
64  +          SUM + (C0)
65  END

Cheers,
ÁM

"To live or die by your own sword one must first learn to wield it aptly."
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP-41 Internal Rate of Return (IRR) - Ángel Martin - 11-03-2024 08:02 AM



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