Message273833
That's clever, Serhiy! Where did it come from? It's not Newton's method, but it also appears to enjoy quadratic convergence.
As to speed, why are you asking? You should be able to time it, yes? On my box, it's about 6 times slower than the last code I posted. I assume (but don't know) that's because + - * / have trivial cost compared to power() and ln(), and your code uses two ln() while the last code I posted uses only one power(). Also, my power() has an exact integer exponent, which - for whatever reasons - appears to run much faster than using a non-integer Decimal exponent. It's for the latter reason that I didn't suggest just doing `return float(D(x) ** (D(1)/n))` (much slower).
Or maybe it's "a platform thing". FYI, I'm using the released Python 3.5.2 on 64-bit Win 10 Pro. |
|
Date |
User |
Action |
Args |
2016-08-28 17:49:44 | tim.peters | set | recipients:
+ tim.peters, rhettinger, mark.dickinson, vstinner, ned.deily, steven.daprano, martin.panter, serhiy.storchaka |
2016-08-28 17:49:44 | tim.peters | set | messageid: <1472406584.58.0.822285355809.issue27761@psf.upfronthosting.co.za> |
2016-08-28 17:49:44 | tim.peters | link | issue27761 messages |
2016-08-28 17:49:44 | tim.peters | create | |
|