When does x^log(y) = y^log(x)?

In this blog post, when I write \log(x), I mean the natural logarithm, or log base e, i.e., \ln(x).

A discussion on a pull request got me thinking about this question: what are the solutions to the complex equation x^{\log{(y)}} = y^{\log(x)}?  At the outset, they look like different expressions.  But clearly there some solutions. For example, if x = y, then obviously the two expressions will be the same.  We probably should exclude x = y = 0, though note that even if 0^{\log(0)} is well-defined (probably if it is it is either 0 or complex \infty), it will be the same well-defined value. But for the remainder of this blog post, I’ll assume that x and y are nonzero.

Now, observe that if we apply \log to both sides of the equation, we get \log{\left(x^{\log(y)}\right )} = \log {\left (y^{\log(x)}\right )}.  Now, supposing that we can apply the famous logarithm exponent rule, we would get \log(x)\log(y) = \log(y)\log(x), which means that if additionally \log is one-to-one, we would have that the original expressions must be equal.

The second question, that of injectivity, is easier to answer than the first, so I’ll address it first.  Note that the complex exponential is not one-to-one, because for example e^0 = e^{2\pi i} = 1.  But we still define the complex logarithm as the “inverse” of the complex exponential.  What this really means is that the complex logarithm is strictly speaking not a function, because it is not well-defined. Recall that the definition of one-to-one means that f(x) = f(y) implies x = y, and that the definition of well-defined is that x = y implies f(x) = f(y).  It is clear to see here that f being one-to-one is the same as f^{-1} being well-defined and visa-versa (f^{-1} here is the same loose definition of an inverse as saying that the complex logarithm is the inverse of the complex exponential).

So note that the complex logarithm is not well-defined exactly because the complex exponential is not one-to-one.  We of course fix this problem by making it well-defined, i.e., it normally is multivalued, but we pick a single value consistently (i.e., we pick a branch), so that it is well-defined.  For the remainder of this blog post, I will assume the standard choice of branch cut for the complex logarithm, i.e., the branch cut is along the negative axis, and we choose the branch where, for x > 0, \log(x) is real and \log(-x) = \log(x) + i\pi.

My point here is that we automatically know that the complex logarithm is one-to-one because we know that the complex exponential is well-defined.

So our question boils down to, when does the identity \log{\left (z^a\right)} = a \log(z) hold?  In SymPy, this identity is only applied by expand_log() or logcombine() when a is real and z is positive, so let us assume that we know that it holds under those conditions. Note that it also holds for some other values too.  For example, by our definition \log{\left (e^{i\pi}\right)} = \log(-1) = \log(1) + i\pi = i\pi = i\pi\log(e).  For our example, this means that x = e, y = -1 is a non-trivial solution (non-trivial meaning x \neq y).   Actually, the way that the complex logarithm being the “inverse” of the complex exponential works is that e^{\log(x)} = x for all x (on the other hand \log{\left(e^x\right)} \neq x in general), so that if x = e, then x^{\log(y)} = e^{\log(y)} = y and y^{\log(x)} = y^{\log(e)} = y^1 = y.  In other words, x = e is always a solution, for any y\, (\neq 0) (and similarly y = e for all x).  In terms of our question of when \log{\left(z^a\right)} = a\log(z), this just says that this always true for a = \log(e) = 1, regardless of z, which is obvious.  We can also notice that this identity always holds for a = 0, regardless of z. In terms of our original equation, this means that x = e^0 = 1 is a solution for all y (and as before, y = 1 for all x).

Note that z > 0 and a real corresponds to x, y > 0 and \log(x), \log(y) real, respectively, (which are the same condition).  So we have so far that the following are solutions to x^{\log(y)} = y^{\log(x)}:

  • x, y > 0
  • x = y
  • x = e, y arbitrary
  • y = e, x arbitrary
  • x = 1, y arbitrary
  • y = 1, x arbitrary

Now let’s look at some cases where \log{\left (z^a\right)} \neq a\log(z).  If z < 0 and a is a nonzero even integer, then z^a > 0 so \log{\left (z^a \right)}) = \log{\left (\left (-z\right )^a \right )} = a\log(-z), whereas a\log(z) = a(\log(-z) + i\pi), which are different by our assumption that a \neq 0.  If a is an odd integer not equal to 1, then z^a < 0, so \log{\left (z^a \right)} = \log{\left (-z^a \right )} + i\pi = $latex \log{\left (\left(- z\right)^{a} \right )} + i\pi$ WordPress is refusing to render this. It should be log((-z)^a) + iπ = a\log(-z) + i\pi, whereas a\log(z) = a(\log(-z) + i\pi) again, which is not the same because a \neq 1. This means that if we let x < 0 and y = e^a, where a \neq 0, 1, we get a non-solution (and the same if we swap x and y).

This is as far as I got tonight. WordPress is arbitrarily not rendering that LaTeX for no good reason. That and the very ugly LaTeX images is pissing me off (why wordpress.com hasn't switched to MathJaX yet is beyond me). The next time I get some free time, I am going to seriously consider switching my blog to something hosted on GitHub, probably using the IPython notebook. I welcome any hints people can give me on that, especially concerning migrating pages from this blog.

Here is some work on finding the rest of the solutions: the general definition of \log(x) is \log(|x|) + i\arg(x), where \arg(x) is chosen in (-\pi, \pi]. Therefore, if \log{\left(z^a\right )} = a\log(z), we must have \arg(z^a) = a\arg(z). I believe a description of all such complex z and a will give all solutions x = z, y = e^a (and y = z, x = e^a) to x^{\log(y)} = y^{\log(x)}. I need to verify that, though, and I also need to think about how to describe such z and a. I will (hopefully) continue this post later, either by editing this one or writing a new one (depending on how much more I come up with).

Any comments to this post are welcome. I know you can't preview comments, but if you want to use math, just write it as $latex math$ (like $latex \log(x)$ for \log(x)). If you mess something up, I’ll edit your comment and fix it.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: