[New-bugs-announce] [issue27353] Add nroot function to math

Steven D'Aprano report at bugs.python.org
Sun Jun 19 20:22:40 EDT 2016

New submission from Steven D'Aprano:

For Issue27181 (add geometric mean to statistics module), I need a function to calculate nth roots that is more accurate than pow(x, 1/n). E.g. math.pow(1000, 1/3) returns 9.999999999999998 instead of 10.0.

I have a pure-Python implementation of nroot which I believe is satisfactory, and I could use that, but I'm uncomfortable about making it a public function in statistics. It's not really a statistics function, its more general, and I think it would be generally useful enough that it should go into math.

To recap the options:

- leave nroot in statistics as a private function;
- leave it in statistics, but make it public;
- add it to math

I'm willing to do the first if there is no other alternative, reluctant to do the second, and think that the third is the most useful, but I don't have the ability to write a pure C version. If the math library was written in Python that would be the obvious place for it.

components: Library (Lib)
messages: 268875
nosy: steven.daprano
priority: normal
severity: normal
status: open
title: Add nroot function to math
type: enhancement
versions: Python 3.6

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list