Re: Programming Programmable Calculators Message #32 Posted by Jeff Kearns on 4 Jan 2008, 6:28 p.m., in response to message #30 by Stefan Vorkoetter
I am a mechanical engineer and I have only posted once or twice on this board so please bear with me for making a lengthy post. I have written (and copied/adapted) programs for my 15C and 32sii for all sorts of applications in the past 15 years, including: piping systems design (conduit flow ~50 lines) as a marine engineer, determination of drilling parameters for PCB drilling, pressure vessel design and compressed air dryer sizing. I have often found it more convenient to use the programmable calculator rather than fire up the applicable utility on the PC. Also, prior to acquiring the Advantage module for my 41C (and later the 49G+), I used my 32sII quite a bit for Statistics applications  tStatistics, ANOVA etc. I still do in fact. These were somewhat longer than 4liners... I still find entering data for small data sets faster on the calculator compared to Minitab or Excel.
Most of all, I have found the TVM equation to be among the most valuable formulas in my arsenal. There is a great 38liner TVM program that I often use for each of my Pioneers (32sII, 33s, 35s). I got this program on this site but cannot remember where... It is more accurate than the 'equation'. I am including the listing below.
It is a relatively short program  38 steps (as compared to a 108 line version for the HP 15C) that literally turns your calculator into an 'accurate' financial calculator on par with any financial calculator like the HP 12C or others. The problem with most TVM programs that just interpret the TVM equation, is that roundoff error  when the calculator rounds to 10 (HP15C) or 12 (HP32s) significant digits  causes inaccuracies when the interest rate per compounding period is quite small and/or the number of compounding periods is very large.
A classic example from the HP 15C Advanced Functions Handbook is where a lady is compensated for her thoughts for one year at $0.01/second at an annual interest rate of 11.25% compounded every second. In this case the number of seconds in a year is simplified to equal n=60*60*24*365. If you simply program the equation into your calculator (or in the case of the 32 sii, enter it as an equation), you get a total of $376,877.67 on the 15C and $334,045.36 on the 32s. The bank account, however, is found to only hold $333,783.35. This program avoids rounding error by using the natural logarithm in such a way as to not discard precious significant digits of i/n.
Here is the code for the 32s/ 32sii/ 33s/ and 35s.
Variables:
B: present value or "base" value
P: payment
n: periods
i: interest rate in %
E: end/begin modes
F: future value
Equation:
B*(1+i)^n + P*((1+i)^n1)*(1/i+E) + F = 0
(1+i)^n = e^(n*ln(1+i)) = i'
> B*i' + P*(i'1)*(1/i+E) + F = 0
Routine:
T01 LBL T
T02 INPUT N
T03 INPUT I
T04 INPUT B
T05 INPUT P
T06 INPUT F
T07 INPUT E
T08 RCL I
T09 100
T10 /
T11 ENTER
T12 ENTER
T13 1
T14 +
T15 LN
T16 x<>y !switch x with y
T17 LASTx
T18 1
T19 X<>Y? !x not equal to y?
T20 
T21 /
T22 *
T23 RCL* N
T24 e^x
T25 RCL* B
T26 LASTx
T27 1
T28 
T29 RCL* P
T30 RCL I
T31 100
T32 /
T33 1/X
T34 RCL+ E
T35 *
T36 +
T37 RCL+ F
T38 RTN
Regards,
Jeff Kearns
