Solving for the derivative of absolute value, gone wrong The absolute value $|x|$ can be represented as $\sqrt{x^{2}}$, as per this question.
Let $f(x) = |x| = \sqrt{x^{2}}$. Solving for $f'(x)$, let $u = x^{2}$. Then,
\begin{align*}\frac{df}{dx} &= \frac{df}{du}\cdot\frac{du}{dx} \\ &= \frac{d}{du}(\sqrt{u})\cdot\frac{d}{dx}(x^{2}) \\ &=\frac{1}{2\sqrt{u}}\cdot2x \\ &= \frac{x}{\sqrt{x^{2}}} \\ &= \frac{x}{|x|}\end{align*}
We can also see that $\sqrt{x^{2}} = \left(\sqrt{x}\right)^{2}$. Then, let $u = \sqrt{x}$. Solving for $f'(x)$,
\begin{align*}\frac{df}{dx} &= \frac{df}{du}\cdot\frac{du}{dx} \\ &= \frac{d}{du}(u^{2})\cdot\frac{d}{dx}(\sqrt{x}) \\ &= 2u\cdot \frac{1}{2\sqrt{x}} \\ &= \frac{\sqrt{x}}{\sqrt{x}} \\ &= 1\end{align*}
I think the problem here is by letting $u = \sqrt{x}$. What seems to be the problem?

Consider real valued functions $f(x)=\sqrt { x^2}$ and  $g(x)=(\sqrt{ x})^2$. $f$ and $g$ have different domains. Domain of $f=\mathbb R$ and that of $g$ is $[0,\infty)$ and hence $f$ and $g$ are not the same. 
We'll have $f(x)=g(x)$ if $x\in [0,\infty)$. 
Therefore in second part, you have unknowingly assumed that $x\gt 0$ and therefore derivative is $1$ which tallies with your result in first part.
