# Solve for $n$ and $m$ [exponents]

How many possibilities are there for $n$ and $m$ when given this equation?

$n^m$ = $m^n$

How many possibilities are there when dealing with positive integers? What about any integers? Or fractions and decimals?

Please include if there are a pattern to the numbers; that is, if any exist

Bonus: What if we open it up to imaginary numbers? Complex numbers included!

• When you say fractions and decimals, do you mean rational numbers? Terminating decimals? Or any real numbers? – xnor Nov 6 '14 at 0:40
• Fractions and decimals could include anything that can be expressed as a fraction or decimal, this includes repeating decimals, irrational, even pi. – warspyking Nov 6 '14 at 0:41
• So the real numbers, then. – Joe Z. Nov 6 '14 at 0:41
• @Joe Z. I edited the question to include a "bonus" – warspyking Nov 6 '14 at 0:43
• By imaginary, do you mean pure imaginary, or complex numbers? – Hao Ye Nov 6 '14 at 0:43

Obviously, $m=n$ is always a solution, so we restrict ourselves to $m \neq n$.

For positive $m,n$, the equation is equivalent to $\frac{\ln m}{m} = \frac{\ln n}{n}$. So, we are looking for collisions in the function $f(x) = \ln(x) / x$. Taking derivatives, we see that it has a unique local maximum at $x=e$ and falls to 0 as $x \to \infty$. So, there are a continuum of real solutions: each real value $n>e$ has a counterpart $m$ with $1<m<e$.

For natural numbers, the above observation limits the lesser number $m$ to $2$, so the only solution is the pair $(2,4)$.

There are no further solutions among integers. The 0 and -1 cases can be eliminated separately. If one number is negative and one is positive, one exponent will be less in one in absolute value, and the other greater. Finally, if both are negative (well-defined if only both are odd), taking the negative reciprocal gives a positive integer solution, of which there are none for odds.

For the complex case, the problem is not well-defined because the complex exponential (or, logarithm) is multivalued.

• I was writing a solution, but now everyone's beating me to the punch. D: – Joe Z. Nov 6 '14 at 0:56
• I would accept this but it does not answer the negatives/fractions/decimals or the bonus (the bonus isn't required but if an answer includes it I'd accept it.) – warspyking Nov 6 '14 at 1:00
• @warspyking I address the real case in the first paragraph. I added a paragraph about the integer case. I don't believe the complex case is well-defined -- you'd need to specify what branch you're taking. – xnor Nov 6 '14 at 1:07
• When I say imaginary/complex numbers I mean just that. For example; 10+5i – warspyking Nov 6 '14 at 1:09
• Sure, but say, (1+2*i)^(1/5) has five different possible values x with x^5=1+2*i. How do I know which one I take? – xnor Nov 6 '14 at 1:12


In any algebraic system that supports exponentiation, $m = n$ is a trivial, valid solution.

If $m \neq n$ is enforced, then in the natural numbers, $2^4 = 4^2$ is the only solution.

This is easy to see if we try and figure out the solution for the real numbers.

In the real numbers, things get a little tricky. Suppose we start with the equation $m^n = n^m$. Then, if we start taking logarithms and moving things around, we get:

\begin{align} m^n &= n^m\\ \log m^n &= \log n^m\\ n \log m &= m \log n\\ \frac{\log m}{m} &= \frac{\log n}{n}\\ \end{align}

We've assumed that $m$ and $n$ are both strictly greater than $0$, because otherwise $\log m$ or $\log n$ is undefined. Now, let's analyze the behaviour of $m$ and $n$ in the intervals $(0, 1]$ and $(1, \infty)$.

Let $f(x) = \frac{\log x}{x}$. $\deriv{f}{x}$ is equal to $\frac{1 - \log x}{x^2}$ by the quotient rule. In $(0, 1]$, this is always positive, and therefore the function is monotone in $(0, 1]$. This means that there cannot be two different values in the interval $(0, 1]$ that have equal values of $f(x)$. However, in $(1, \infty)$, $f(x)$ is always positive, and in $(0, 1]$ it's either 0 or negative, so no value from $(0, 1]$ can be paired with a value greater than $1$ either. Thus, we've determined that $m$ and $n$ must be strictly greater than $1$ as well.

Let's continue to analyze $f(x)$ when $x > 1$. When $1 < x < e$, $f'(x)$ is positive. When $x > e$, $f'(x)$ is negative.

Therefore, $f'(x)$ has a single local maximum on $(1, \infty)$ at $e$, and is monotone in either direction (and therefore injective for that interval). Moreover, $\lim_{x \to \infty} f(x) = 0$, so the function is surjective and therefore bijective when mapping from $(e, \infty)$ to $(0, \frac{1}{e})$, as it is when mapping from $(1, e)$ to $(0, \frac{1}{e})$.

So, for any number $1 < x < e$, there exists exactly one other value $e < y < \infty$ such that $x^y = y^x$.

Since the only integer in $1 < x < e$ is 2, $2^4 = 4^2$ is the only solution in the positive integers. (Note that ${-2}^{-4} = {-4}^{-2}$ is also a solution in the integers in general, but we assumed above that $m$ and $n$ were positive. $-2$ and $-4$ are not part of this analytic mapping that we came up with above, because in general, real non-integer exponents of negative numbers are not defined in the real numbers.)

But now we need to come up with a way to characterize all the ordered pairs $(m, n)$ that satisfy this equation in the real numbers.

We can't just solve the equation for $n$ directly by plugging $m$ in - the inverse of $f(x) = \frac{\log x}{x}$ involves the Lambert W function, which can't be expressed in terms of elementary functions.

So instead, we need something more clever. Suppose $n = am$ for some $a \in \mathbb R, a > 1$. Then the equation becomes

\begin{align} \frac{\log m}{m} &= \frac{\log am}{am}\\ \frac{\log m}{m} &= \frac{\log a + \log m}{am}\\ a \log m &= \log a + \log m\\ (a - 1) \log m &= \log a\\ \log m &= \frac{\log a}{a-1}\\ m &= e^{\frac{\log a}{a-1}}\\ m &= \sqrt[a-1]{a}\\ \end{align}

So we get an equation for $m$ in terms of $a$, which allows us to deduce $n$ as well. If $m = \sqrt[a-1] a$, then $n$ just equals $a\sqrt[a-1]a$.

If we write $a$ in the form of $1 + \frac 1x$, we get $m = (1 + \frac 1x)^x$ and $n = (1 + \frac 1x)^{x+1}$, which is a solution for all positive real numbers $x$. It so happens that the $(2, 4)$ case arises when $x = 1$.

Complex numbers to come later.

• Great solution! I didn't realize you could relate m and n via elementary functions. – xnor Nov 6 '14 at 3:46
• I'll be honest, this problem feels much more like a Math.SE problem than a Puzzling.SE one. – Joe Z. Nov 6 '14 at 6:22
• @Joe wow... Can't wait to see complex numbers! – warspyking Nov 6 '14 at 11:05

Short answer, infinite: of the form $n = m$.

There is at least one other: $(2,4)$.

EDIT: Set $n = m^x$, then $n^m = (m^x)^m = m^{m^x}$ implying $mx = m^x$, and $x = m^{(x-1)}$. This should have 2 solutions for $m > 1$, one of which is the trivial $x = 1$, which leads to $m = n$, but the other will produce $m \ne n$.

• @xnor just noticed and was editing. :) – Hao Ye Nov 6 '14 at 0:46