Comparing Powers with Different Bases Using Logarithms?

I looked all over to see if a question like this had already been answered, but I couldn't find it. So here goes:

I need a general formula for comparing two (insanely huge) powers. I'm pretty sure the best way to go about this would be using logarithms, but that's as far as I've gotten. For a specific example, here are two powers I need to compare (no this isn't homework):

Is $632382^{518061}$ smaller, greater, or equal to $519432^{525806}$?

For small powers like $2^{11}$ and $3^7$, it is quite possible to calculate the power, and then compare, but for huge powers like the ones above, that would be ridiculous because both numbers are more than $3\times 10^9$ (three million) digits long.

All I need is the general formula for comparing $a^b$ with $c^d$ using logarithms. Please use letters if possible.

(In case you're wondering why I'm asking this, I'm trying to solve this problem. I've done some research, read through my Calculus textbook, searched online; nothing. Help please?

Thanks so much.

• Use the fact that $\log (a^b)=a\log b$ and compare both numbers. – azarel Mar 9 '12 at 17:09
• We have $a^b<c^d$ if and only if $\log(a^b)<\log(c^d)$, or equivalently if and only if $b\log a<d\log c$. Here by $\log$ we mean logarithm to any base $>1$ that you like. However, that is not necessarily helpful for a problem such as the one you refer to, since one must manage the large number of comparisons efficiently, and also worry about near equalities. – André Nicolas Mar 9 '12 at 17:15
• +1: For "I searched already". btw, related: math.stackexchange.com/questions/97049/… – Aryabhata Mar 9 '12 at 17:19
• @azarel, better check that equation! – Gerry Myerson Mar 10 '12 at 6:45

As you mentioned it is easier to compare these numbers using logarithms rather than their true values. So instead of using $m^n$ we can look at $\log m^n = n\log m$.

If you are writing a program then you would start by setting MAX = $a\log b$ and MIN = $a\log b$. Then for every number after, $m^n$, divide MAX by $n\log m$. If the result is less than one then the new number is larger so replace MAX with the new number. If the result is greater than one then the new number is smaller and there is nothing to do. Do the similar thing with MIN. After you have gone through all the numbers MAX should hold the largest value and MIN should hold the smallest value.

This is of course assuming what you are using to calculate these values can compute $n\log m$ for the large values you need.