Compare big exponentials

Let's talk about algorithms!

Moderator: Board moderators

Post Reply
mrlinx
New poster
Posts: 3
Joined: Wed May 06, 2009 5:03 am

Compare big exponentials

Post by mrlinx »

I stumbled across a problem a long time ago where I was given several exponencial numbers, and was my mission to find the largest. I'm trying to remember what is the best way to solve this... I think there was a property in logarithms that allowed this to be made quite fast, but can't seem to get it to work.

Example, from this list, which is the biggest:
2^3^4^5
6^1^3^6
9^3^2^2
8^8^8^8

Thanks ;)
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Re: Compare big exponentials

Post by sohel »

I think this should work.

Suppose we are comparing a^b^c and d^e^f,

assume d = a^x
.. x = log(d) / log(a)

and so d^e^f = (a^x)^e^f = a^(xe)^f
then we have to compare b^c with (xe)^f and see which one is bigger!! This can be found using the above method.
mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Re: Compare big exponentials

Post by mf »

sohel wrote:and so d^e^f = (a^x)^e^f = a^(xe)^f
No, (a^x)^e^f = a^(x e^f)
(Remember that exponentiation is right-associative: a^b^c = a^(b^c).)
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Re: Compare big exponentials

Post by sohel »

Oops! You are, of course, right. :)
Then, is there any solution with logarithms, or do we have to bring number theoretic algorithms into action?
Post Reply

Return to “Algorithms”