Message273759
What if use pow() with exactly represented degree in approximating step?
def rootn(x, n):
g = x**(1.0/n)
m = 1 << (n-1).bit_length()
if n != m:
g = (x*g**(m-n))**(1.0/m)
return g
Maybe it needs several iterations, because it converges slower than Newton approximation. But every step can be faster. |
|
Date |
User |
Action |
Args |
2016-08-27 05:03:25 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, tim.peters, rhettinger, mark.dickinson, vstinner, ned.deily, steven.daprano, martin.panter |
2016-08-27 05:03:25 | serhiy.storchaka | set | messageid: <1472274205.89.0.0686809997068.issue27761@psf.upfronthosting.co.za> |
2016-08-27 05:03:25 | serhiy.storchaka | link | issue27761 messages |
2016-08-27 05:03:25 | serhiy.storchaka | create | |
|