Archive for 24th August 2003

Check Your Math!

“Rick, how do you know Wheatworks Software’s financial calculators are accurate?”

Elementary school students are taught the importance of checking and double-checking their math. It’s easy when the problem is “2 + 6″, but how does one double-check the results of an algorithm designed to calculate the modified internal rate of return for a 30 year series of monthly cash flows?

Very tediously …

Here’s how it’s done at Wheatworks:

The initial calculation routine is drafted in pseudocode that lays out the general algorithm for a particular mathematical formula. This pseudocode is then fleshed out into Object Pascal.

A large set of example problems is created with an eye towards covering all the possible variations the algorithm is expected to accomodate. These problems are designed to address positive, negative, zero, and out of range variables.

Each of the problems in the example set is solved using one of my favorite toys/tools… an HP hand held calculator. An assortment is scattered across my desk as I write this post; a 19Bii, a 12C, an 18C, a 10Bii and a 17Bii. (More about these in a later post)

Next the algorithm is tested against the known results of the example set and tweaked until the algorithm’s results match the known results as generated by an HP.

After the algorithm has passed the example set a program is created for the algorithm that reads in a larger set of problems from a test file containing problem sets of variables with their expected results as determined using the HP handheld.

The test program generates an answer for each problem in the test file and exports the problem variables, expected answer and calculated answer to a results file. Calculated answers that differ from a known answer identify errors in the algorithm which is then tweaked until the calculated answers are accurate.

After the testing is completed (no errors are generated) the algorithm is placed in our library of financial algorithms and is available for use in Wheatworks’ financial calculators for Windows and our MoneyToys(tm) calculators for the web.