[Math] Comparing Powers with Different Bases Using Logarithms

calculusexponentiationlogarithmsproject euler

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}$?

(The answer is greater than.)

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.

Best Answer

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.