Velocity Reviews > RE: nth root

# RE: nth root

ajaksu
Guest
Posts: n/a

 01-31-2009
On Jan 31, 12:03 pm, Mark Dickinson <(E-Mail Removed)> wrote:
[...]
> t1 = timeit.Timer("x = n**power", "n = 4021503534212915433093809093996098953996019232; power = 1./13")
> t2 = timeit.Timer("x = n**power", "n = 4021503534212915433093809093996098953996019232.; power = 1./13")

And by using a float literal instead of "float
(402150353421291543309...)", (BTW, here -^), it not only is faster but
also a great way make some innocent bystander waste his eyesight
trying to figure out the magic trick

Mark Dickinson
Guest
Posts: n/a

 01-31-2009
On Jan 31, 7:04*pm, ajaksu <(E-Mail Removed)> wrote:
> also a great way make some innocent bystander waste his eyesight
> trying to figure out the magic trick

Oh, come on! At least I put the two lines next to each other!

Mark

Tim Roberts
Guest
Posts: n/a

 02-01-2009
"Tim Roberts" <(E-Mail Removed)> wrote:
>
>Thanks - you're probably right - just my intuition said to me that rather than calculating that the 13th root of 4021503534212915433093809093996098953996019232
>is 3221.2904208350265....
>there must be a quicker way of finding out its between 3221 and 3222....
>
>....but perhaps not.

Also, remember that the number you computed there is not really the 13th
root of 4021503534212915433093809093996098953996019232. When you convert
it to float to do the exponentiation, you're losing everything after the
15th significant digit. Of course, if all you're looking for is the
nearest integer, that's not very relevant.

Do you really need the absolute number? You could take log(x)/13 and work
with the log of the results. I suspect (without trying it) that's faster
than the exponentiation.

From one Tim Roberts to another.
--
Tim Roberts, http://www.velocityreviews.com/forums/(E-Mail Removed)
Providenza & Boekelheide, Inc.