Wednesday, September 2, 2020

Code Monkey

 This might be an odd set of characters, but it will mean something to someone.

<< 200 / 1 + 6 INV ^ 1 -100 * >>

The << and >> indicate the start and end of a program for the HP48G calculator and the mode of calculation is reverse polish notation, or RPN, so you may ask what little secret does that piece of programming titled CINT unlock?

I've been playing about on the HP-12C calculator and the TVM functions calculate mortgage payments based on the USA, and perhaps the rest of the worlds, rules.

Loan Amount $100,000 with interest rate 6% per Annum, 25 year mortgage.

The HP-12C calculates that over the 25 years, the monthly mortgage payment would be $644.30

I asked my East Coast buddy, Graeme Wright, to send me his spreadsheet that we would use long ago when we had mortgages, the spreadsheet was always correct to the exact penny when compared to printouts from the banks.

It said the monthly payment would be $639.81

The question was, why the difference?

Canadian Mortgage payments are required by law to be compounded twice yearly, so for a standard TVM calculation to work, the equivalent monthly interest rate needs to be calculated. In the above example, for the USA formula, the monthly interest rate is 6/12 = 0.500 and if I return to my little piece of program code at the top, the CINT program code will do the following if 6 is the number on the stack (X) when it is started, remember, this is in RPN so it acts a little differently than algebraic logic and does not require brackets, so I'll recreate the algebraic equivalent and put them back in.

(((X/200 + 1)^(1/6))-1)*100 = 0.49386

I may have put too many brackets in there, but no harm in that....

This adjusted monthly interest rate, when plugged into the intrinsic TVM solver of the HP-12C produces the monthly payment of $639.81 which is all fine and dandy, but not so sadly here in my advancing years there is little use for this type of financial arithmetic besides the occasional daily amusement.

Just call me Chuckles.


 



1 comment: