Weighted Average
The weighted average uses the statistic registers and leaves avg(y) weighted by x in y, and avg(x) weighted by y in x:
Lbl 0 -so that it coincides in the same key as avg(x)
rcl 7
rcl / 3
rcl 7
rcl / 5
rtn
NPV and IRR
The Net Present Value and IRR are a little longer. Requires 11 registers and is valid for up to 10 periods. Data is not destroyed and can be used with other interest rates. I take care of not using labels used by TVM!
Net Present Value: It takes the following arguments:
Number of periods: register .1
Initial cashflow: register 0
cashflows for periods 1 to 9: registers 1 to 9 (how clever ;-))
discount rate in %: register x
NPV result: register x
LBL 1
EEX
2 - from % to decimal
/
1
+
1/x - calculate 1/(1+i)
ENTER
ENTER
ENTER - to load the stack with 1/(1+i)
RCL .1 - number of periods (so that is is kept for further trials with other interest rates)
STO I
CLX
LBL .2 - loop for periods
RCL + (I)
X - calculates f(n) = (f(n-1)+ I(n))/(1+i)
DSE I
GTO .2 - Return if not 0
RCL + 0 - Add start cashflow
RTN
IRR - this is the elegance of the HP-15 - just load your guesses in x and I and use SOLVE ( f SOLVE 1)