For which complex $a,\,b,\,c$ does $(a^b)^c=a^{bc}$ hold? Wolfram Mathematica simplifies $(a^b)^c$ to $a^{bc}$ only for positive real $a, b$ and $c$. See W|A output.
I've previously been struggling to understand why does $\dfrac{\log(a^b)}{\log(a)}=b$ and $\log(a^b)=b\log(a)$ not always hold (while I was always thinking of logarithms of positive reals as $\log_a(a^b)=\dfrac{\log(a^b)}{\log(a)}=\dfrac{b\log(a)}{\log(a)}=b$ before I've started to self-study complexes), but then learned about branch cutting of multifunctions, so that natural logarithm can be defined to be a function by first finding a set of $w$ for each $z$, so that $z=e^w$ (inverse natural exponential), and then somehow (no matter how) selecting a unique solution $w$ from that set, so that $\forall{z}\exists!{w}$, yielding a function $z\mapsto{w}$. This results in some sort of discontinuity where solutions are being dropped:

This is done because functions are generally more easy to deal with than multifunctions. Wolfram's convention is to define $\log(z)$ as the inverse of $e^z$ such that $\log(1)=0$ and such that the branch cut discontinuity is at ${(-\infty;0]}$. I know this is somewhat unpopular to think of natural logarithm as a single-valued function, but I am going to follow this convention (I personally think it is well-justified, at least that's what happens with $\operatorname{arcsin}$, $\operatorname{sqrt}$, etc, so in fact I am comfortable with it).
Then it is clear for me why is $\dfrac{\log\left((-2)^{-3}\right)}{\log(-2)}\approx{0.814319+0.841574i}\neq{-3}$, while $-3$ perfectly satisfies the equation $(-2)^x=(-2)^{-3}$.
Given that $\log(a^b)=b\log(a)$ holds for positive real $a, b$ only, I thought how would I then solve equations of form $a^x=b$, where $a,b$ are complexes and not necessarily positive reals, since my first step was always to rewrite everything to base $e$:
$$e^{\log(a^x)}=e^{\log(b)}$$
and then carry the exponent out of the logarithm:
$$e^{x\log(a)}=e^{\log(b)}$$
(adding $2\pi i k,\,k\in\mathbb{Z}$ to any exponent and then eliminating the exponentials yields the result). So I've asked on ##math, where I've been pointed out that another way to rewrite $a^b$ to base $e$ is using the definition of the logarithm: $a^b=(a)^b=(e^{\log(a)})^b=e^{b\log(a)}$. I was happy with that (and even solved a $(-2)^x=-3$ for $x$ just for fun using this approach, see here) but some time later I have realized that this neither does not actually work for arbitrary complex $a$ and $b$!
$$1=1^{1/2}=((-1)^2)^{1/2}=(-1)^{2\cdot\frac{1}{2}}=(-1)^1=-1$$
The rule $(a^b)^c$, as I was told by W|A, requires $a, b, c$ to be positive reals.
When I pointed that out on ##math, I was told that $a^b=e^{b\log(a)}$ is by definition of complex exponentiation. I've checked, and Wolfram Mathematica agreed with this identity. Too good!
But then I realized from these something must not be true:


*

*$(a^b)^c=a^{bc}$ holds only for positive real $a,b,c$

*$\forall{a,b\in\mathbb{C}}:a^b=e^{b\log(a)}$

*$\forall{a\in\mathbb{C}}:a=e^{log(a)}$


The latter is the definition of the logarithm, so should be true. The second also must be true, otherwise I do not know how to solve equations. Hence:
$$a^c=e^{c\log(a)}$$
is by the definition of complex exponentiation, just as I was told. Then, rewriting $a$ in the LHS using the definition of logarithm:
$$a=e^{log(a)}$$
$$\left(e^{log(a)}\right)^c=e^{c\log(a)}$$
Now, since that for every complex $b$ there exists a $z$ such that $b=\log(z)$, we can rewrite $\log(a)=b$:
$$(e^b)^c=e^{bc}$$
for all complex $b,c$! So, what is that?
I've made a mistake? Or is base $a=e$ that special?
Or is in fact (I suspect) one just needs to require $a$ to be positive real, and $b,c$ are in fact irrelevant?
$$\forall{a}\in\mathbb{R}\forall{b,c}\in\mathbb{C}:a>0\implies{(a^b)^c=a^{bc}}$$
Have I found a bug in Mathematica and W|A or made a huge stupid mistake leading myself to drastic misunderstanding?
P. S. This is my first post at MSE, I am not a math major, just a hobbyist, so sorry if I am struggling at basics here. Also sorry for my English: it is not my native language.

Edit: thank you @Andrew for your answer.

$\forall{a,b,c}:-\pi<\Im(b\log(a))\leq\pi\implies(a^b)^c=a^{bc}$

Very clear and straightforward, works flawlessly.
But it appears that though the implication is obviously true, there are more cases (read "values of $a,\,b,\,c$") from which $(a^b)^c=a^{bc}$ does follow, i.e. I found that it is true for $c\in\mathbb{Z}$ and arbitrary complex $a,\,b$, for example:
$$\big((-2)^{-3}\big)^{-2}=(-2)^{(-3)\times(-2)};$$
$$\left(\frac{1}{(-2)^3}\right)^{-2}=(-2)^{6};$$
$$\left(-\frac{1}{8}\right)^{-2}=64;$$
$$\left(-8\right)^2=64;$$
$$64=64.$$
For this case, $b\log(a)=-3\log(-2)=-3(\log(2)+i\pi)=-3\log(2)-3i\pi$, and hence $\Im(-3\log(2)-3i\pi)=-3\pi\notin{({-\pi;\pi}]}$, therefore @Andrew's implication does not cover all cases.
So, is there any more solutions of $(a^b)^c=a^{bc}$?
 A: If we agree $\log z$ has imaginary part between $-\pi$ and $\pi$ and is defined only on the set $D = \mathbf{C} \setminus(-\infty, 0]$, then
\begin{align*}
\exp(\log z) &= z\quad\text{for all $z$ in $D$,} \\
\log(\exp z) &= z\quad\text{for all $z$ with imaginary part between $-\pi$ and $\pi$.}
\end{align*}
If the imaginary part of $z$ is between $(2k - 1)\pi$ and $(2k + 1)\pi$, then
$$
\log(\exp z) = z - 2\pi ki
\tag{1}
$$
because $z - 2\pi ki$ has imaginary part between $-\pi$ and $\pi$.
Defining $a^{b} = \exp(b \log a)$, we have
\begin{align*}
(a^{b})^{c}
  &= \exp\bigl(c \log(a^{b})\bigr)
  = \exp\bigl(c \log [\exp (b \log a)]\bigr), \\
a^{bc}
  &= \exp(bc \log a).
\end{align*}
If $b \log a$ has imaginary part between $(2k - 1)\pi$ and $(2k + 1)\pi$, then $\log\bigl(\exp(b \log a)\bigr) = b \log a - 2\pi ki$ by (1), so
$$
\exp\bigl(c \log(a^{b})\bigr)
  = \exp\bigl(c(b \log a - 2\pi ki)\bigr)
  = \exp(bc \log a) \exp(-2\pi cki),
$$
which is equal to $a^{bc}$ if and only if $\exp(2\pi cki) = 1$.
In particular, if $b \log a$ has imaginary part between $-\pi$ and $\pi$ (i.e., $k = 0$), or if $c$ is an integer, then
$$
(a^{b})^{c}
  = \exp\bigl(c \log(a^{b})\bigr)
  = \exp\bigl(c \log(\exp b \log a)\bigr)
  = \exp(bc \log a) = a^{bc}.
$$
A: This is a late post. But just to make it clear for future readers, the error in your question is here:

... for every complex $b$ there exists a $z$ such that $b=\log(z)$, ...

This is false since you already chose $\log$ to be a function, and you cannot choose to have both $\log(1) = 0$ and $\log(1) = 2πi$, which implies that either $0$ or $2πi$ will not be a possible value of $\log$ since $\exp(0) = 1 = \exp(2πi)$. To put it algebraically, it cannot be that we have both $\log(z) = b$ and $\log(w) = b+2πi$ for some complex $b,z,w$, otherwise $z = \exp(b) = \exp(b+2πi) = w$ and hence $\log(z) = \log(w)$, contradicting $b \ne b+2πi$.
