[Python-Dev] calculator module
Andrew P. Lentvorski, Jr.
bsder at allcaps.org
Wed Mar 10 17:15:53 EST 2004
On Wed, 10 Mar 2004, Raymond Hettinger wrote:
> To these, the HP12C financial calculator adds:
> * solve for missing variable in (n i% pv pmt fv)
> * internal rate of return and net present value for a stream of cash
> By "pretty good" implementation, I mean that the implementations should
> remain as straight-forward as possible and neither promise, nor get in a
> snit about being accurate to the last place (i.e. a 9 place
> approximation of gamma would be considered fine).
Pretty good is not "good enough". One of the reasons the HP 12C is so
popular is that every 12C gets *exactly* the same answer for the same
inputs regardless of age, model, etc. The Python version would have to be
a bit exact match to a 12C for that calculation.
In addition, there are going to be requirements for directed rounding to
ensure the stability of some functions over their domains. Directed
rounding generally causes a machine wide pipeline drain and lots of
ancillary machine wide FP effects. Having Python cause FP random FP bugs
in other programs would not be good for its reputation.
Personally, I would rather see extremely good and accurate, but possibly
complex versions of these mathematical functions added into Python proper
with the calculator module simply being a wrapper around the base library
functions. That way, the calculator automatically benefits when the
"state of the art" method in the main library advances or is corrected.
More information about the Python-Dev