Exercise: A first-order linear differential equation with $x^x$ This is a question I'll be giving to my students on a quiz, and I want to have a solution typed up nicely for them. Hopefully posting it as a question here will help future students too. 

For $x>0$, how do you solve the differential equation
$$x^x\dot{y} + \ln\left(x^{x^x}\right)y = 1\,?$$

I'll probably write $\ln\left(x^{x^x}\right)$ as $x^x\ln(x)$ on the quiz though; I don't want them to get tripped up on that since that's not what I'm quizzing them on.
 A: This differential equation looks linear, but let's actually write it in the standard form of a first-order linear differential equation, $\dot{y} + p(x)y = q(x) \newcommand{\ex}{\mathrm{e}}$ before we continue, just to be sure.
\begin{align}
x^x\dot{y} + \ln\left(x^{x^x}\right)y &= 1
\\[0.5em]
x^x\dot{y} + x^x\ln\left(x\right)y &= 1
\\[0.5em]
\dot{y} + \ln\left(x\right)y &= x^{-x}
\end{align}
Since $x>0$, $x^x \neq 0$, so dividing through by $x^x$ doesn't cause any problems. So yeah, it's linear. Nifty! Now we recall that we can solve a first-order linear differential equation by multiplying through by the integrating factor $\ex^{\int p(x) \mathrm{d}x}$ which allows us to "undo the derivative of a product" on the left-hand side. In terms of a general first-order linear differential equation, this looks like
\begin{align}
\dot{y} + p(x)y &= q(x)
\\[0.5em]
\ex^{\int p(x) \mathrm{d}x}\dot{y} + \ex^{\int p(x) \mathrm{d}x}p(x)y &= \ex^{\int p(x) \mathrm{d}x}q(x)
\\[0.5em]
\frac{\mathrm{d}}{\mathrm{d}x}\left(\ex^{\int p(x) \mathrm{d}x}{y}\right) &= \ex^{\int p(x) \mathrm{d}x}q(x)
\,.
\end{align}
For our particular differential equation though, after we remember that $\int \ln(x)\,\mathrm{d}x = x\ln(x)-x$, this integrating factor is
$$
\ex^{\int \ln(x) \mathrm{d}x}
=\ex^{x\ln(x)-x}
=\ex^{\ln(x^x)}\ex^{-x}
=x^x\ex^{-x}
\,,
\color{maroon}{\LARGE^\star}
$$
and our differential equation becomes 
\begin{align}
\dot{y} + \ln\left(x\right)y &= x^{-x}
\\[0.5em]
\ex^{\int \ln(x) \mathrm{d}x}\dot{y} + \ex^{\int \ln(x) \mathrm{d}x}\ln\left(x\right)y &= \ex^{\int \ln(x) \mathrm{d}x}x^{-x}
\\[0.5em]
\frac{\mathrm{d}}{\mathrm{d}x}\left(\ex^{\int \ln(x) \,\mathrm{d}x}y\right) &= \ex^{\int \ln(x) \mathrm{d}x}x^{-x}
\\[0.5em]
\frac{\mathrm{d}}{\mathrm{d}x}\left(x^x\ex^{-x} y\right) &= x^x\ex^{-x}x^{-x}
\\[0.5em]
\frac{\mathrm{d}}{\mathrm{d}x}\left(x^x\ex^{-x} y\right) &= \ex^{-x}
\,.\end{align}
Then by taking the antiderivative of both sides we get
\begin{align}
\int\frac{\mathrm{d}}{\mathrm{d}x}\left(x^x\ex^{-x} y\right) \,\mathrm{d}x &= \int \ex^{-x}\,\mathrm{d}x
\\[0.5em]
x^x\ex^{-x} y &= C-\ex^{-x}
\\[0.5em]
y &= \frac{C-\ex^{-x}}{x^x\ex^{-x}}
\\[0.5em]
y &= \frac{C\ex^x-1}{x^x}
\end{align}
There's no problem dividing through by $\ex^{-x}$ since $\ex^{-x}$ is never zero, so this is our general solution.

$\color{maroon}{\LARGE \star}$ An astute reader might ask at this point, shouldn't there be a constant of integration inside the exponent here? Shouldn't it be $\ex^{x\ln(x)-x+k}$? That astute reader would be correct, but eventually the constant $k$ can be absorbed into the constant $C$ that appears later in the calculation. An explicit calcuation of this can be found in Paul's Lecture Notes, but after you see this once and realize that this is what happens, you can safely drop the constant of integration $k$ that should appear at this step.
A: $$x^xy'+\ln(x^{x^x}) y =1$$
$$x^xy'+x^x\ln x y =1$$
Observe that
$$(x^x)'=(e^ {x \ln x})'=x^x(x \ln x)'=x^x( \ln x +1)$$
Now
$$x^xy'+x^x\ln x y +x^xy=1+x^xy$$
$$(x^xy)'=1+x^xy$$
$$\implies z'=1+z$$
Where $z=x^xy$
It's easy to solve
$$(x^xye^{-x})'=e^{-x}$$
After integration
$$x^xye^{-x}=-e^{-x}+K$$
$$\boxed {y=\frac  {Ke^x-1}{x^x}}$$
