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 
(15C) Simple NPV
05-06-2017, 10:43 AM (This post was last modified: 05-06-2017 11:15 AM by Vtile.)
Post: #1
(15C) Simple NPV
As a happy owner of a miniature clone of 15C for a few days, I quickly searched a NPV functions for a HP15C yesterday, but didn't find any (or google optimisation didn't)! I made at the evening my own, it is my first RPN and 15C program so I assume it is not too sophisticated. Any improvement tips are welcome.

I quickly tested it and getting satisfactory results, but I can not claim to understand the financial calculations theory inside out so use the program at your own risk.

I did use HP12C formula given in the manual for the calculations.

NPV=(CL/(1+i)^0)+(CL/(1+i)^1)+...+(CL/(1+i)^n)

The program reads data from storage registers R1,R2,R3,R4, where
R1: n
R2: i% (in percentage)
R3: NPV (internal)
R4: CL (internal)

Starting conditions are stored in registers R1 and R2, while R3 and R4 are overwritten by program. Uses Label D.

Program assumes CL at the Y register, so when entering a value use [x<>y] or [Enter].

Program returns CL to Y register and NPV in X register. R1 can be recalled for n+1 value of the currently shown NPV.

For ie. 1st example in https://support.office.com/en-us/article...28acf2a568 can be calculated as follows.

0 STO 1
10 STO 2
0 ENTER f D (push the investment 1 year to the future as in example)
-10000 ENTER f D
3000 ENTER f D
4200 ENTER f D
6800 ENTER f D
Result: $1,188.4434 (FIX 4)

Alternative route for the same example
1 STO 1 (push the investment 1 year to the future as in example)
10 STO 2
-10000 ENTER f D
3000 ENTER f D
4200 ENTER f D
6800 ENTER f D
Result: $1,188.4434 (FIX 4)

http://h10032.www1.hp.com/ctg/Manual/c00363319.pdf
Page 60, NPV example.

f CLEAR REG
13 STO 2
-80000 Enter f D
-500 Enter f D
4500 Enter f D
5500 Enter f D
4500 Enter f D
130000 Enter f D
Result: 212.18

First version:
Code:

001 LBL D
002 X<>Y
003 STO 4
004 RCL 1
005 g X=0
006 STO 3
007 R↓  
008 1
009 RCL 2
010 g %
011 +
012 RCL 1
013 Y^X
014 /
015 STO+ 3
016 1
017 STO+ 1
018 RCL 4
019 RCL 3
020 RTN
As a future improvement I need to include an user mode switch somehow at the beginning of the program.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(15C) Simple NPV - Vtile - 05-06-2017 10:43 AM
RE: (15C) Simple NPV - grsbanks - 05-06-2017, 11:43 AM
RE: (15C) Simple NPV - SlideRule - 05-06-2017, 12:34 PM
RE: (15C) Simple NPV - Vtile - 05-06-2017, 06:19 PM



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