How is Mathematica treating $x^x$ when finding roots?

When I enter

Solve[x (-x + x^x) == 0, {x}, Reals]


It returns three roots as

$$\{\{x\to -1\},\{x\to 1\},\{x\to 1\}\}$$

Is MMA treating

  Limit[x^x, x -> 0] = 1


Is that how it is getting that third root?

In some contexts, couldn't $$x = 0$$ also be a root?

I am using MMA 12.1. 1 on Windows 10, X86.

• My guess is simply that it excludes 0 because 0^0 is Indeterminate, but I'm not sure. What's also weird to me is that it duplicates {x -> 1}...how does it count multiplicity here? Usually roots are duplciated for multiplicity reasons, e.g. Solve[x^3 == 0, {x}] gives three copies of {x->0}, but I don't know what's going on here. – thorimur Mar 11 at 22:52

Let's define

f[x_]:= x ( -x + x^x)


now we have

FunctionDomain[ f[x], x]

(x ∈ Integers && x <= -1) || x > 0


As we can see the both solutions returned by Solve belong to the domain of f[x] however x == 0 does not belong to the domain and so it cannot be a solution. Here the system works correctly however in a similar case it failed in a previous version and still does (at least in version 12.1), see e.g. Wrong solution to a simple equation.

As it has been observed x == 1 is a double root. Let's assume that x > 0 than f[x] == 0 is equivalent to Log[x] == x Log[x]  and so (x - 1) Log[x] == 0 and this equation has a double root at x == 1 since $$x-1=0$$ and $$\ln(x)=0$$ for $$x=1$$.

WARNING!!!

Remarks above concern the case with domain specification in Reduce and Solve e.g. Solve[ f[x] == 0, x, Reals] and Reduce[f[x] == 0, x, Reals] however when we restrict the domain by including appropriate ranges for the variable x both functions i.e. Reduce and Solve fail, e.g.

Solve[ f[x] == 0 && -2 <= Im[x] <= 2 && -6 < Re[x] < 6, x]
Reduce[f[x] == 0 && -2 <= Im[x] <= 2 && -6 < Re[x] < 6, x]


The correct solution x == -1 is lost and a wrong "solution" x == 0 is included.

This is a bug!.

• One might also point out that x -> 1 is in fact a double root. For example, Series[x (-x + x^x), {x, 1, 2}], or plotting. – Michael E2 Mar 11 at 23:09
• @MichaelE2 Thanks for this remark, nevertheless I guess that my argument is even simpler. – Artes Mar 11 at 23:27
• @Artes: Thanks for this answer, however, why is it showing $x = 1$ twice? I am not following why it thinks there is a double root here. Is this a bug? You already explained the $x = 0$ case. – Moo Mar 12 at 1:30
• @Moo If $x>0$ then $f(x)=0 \equiv -x+x^x=0 \equiv -x+ e^{x \ln(x)}=0 \equiv \ln(x)= x \ln(x) \equiv (x-1)\ln(x)=0$. Now the both terms i.e. $(x-1)$ and $\ln(x)$ vanish at $x=1$. Right? – Artes Mar 12 at 1:40