<s>[INST] Show that $f(x) = x|x|$ is continuous and differentiable - solution verification? Another exercise I did without any solutions.
I highly doubt this is correct so pls correct me :)

Let $f: \mathbf{R} \rightarrow \mathbf{R}$ be given by $f(x):=x|x| .$ Show that $f$ is continuous and differentiable on $\mathrm{R}$

$$
\begin{array}{l}
\text { Continuous: } \lim _{x \rightarrow c} f(x)=f(c) \\
\begin{aligned}
\lim _{x \rightarrow c} x \cdot|x| &=\lim _{x \rightarrow c} x \cdot \lim _{x \rightarrow c}|x|=f(c) \\
&=\lim _{x \rightarrow c} c \cdot \lim _{x \rightarrow c}|c|=f(c) \\
&=c \cdot|c|=f(c)=c \cdot|c|
\end{aligned}
\end{array}
$$
So $f(x)$ is continuous
Differentiable: show $f^{\prime}(x)$ exists atall $x \in \mathbb{R}$ :
$$
\begin{array}{l}\lim _{h \rightarrow 0} \frac{f(x+h)-f(x)}{h} \\ 
\lim _{h \rightarrow 0} \frac{(x \cdot|x|)+h-(x \cdot|x|)}{h} \\ =\lim _{h \rightarrow 0} \frac{h}{h}=1\end{array}
$$
$$
So f(x) \text { is differentiable }
$$
 [/INST] For $x\neq 0$, $$\begin{align*} \lim_{h\to 0} \frac{f(x+h)-f(x)}{h}&= \lim_{h\to 0} \frac{(x+h)|x+h|-x|x|}{h}\\&=\lim_{h\to 0} \frac{x|x+h| + h|x+h|-x|x|}{h}\\&=\lim_{h\to 0} \frac{x(|x+h|-|x|)+h|x+h|}{h}\\&= \lim_{h\to 0}\frac{x(|x+h|-|x|)}{h} + \frac{h|x+h|}{h}\\&=\bigg[x\lim_{h\to 0}\frac{|x+h|-|x|}{h}\bigg]+|x|\\&=\frac{x^2}{|x|}+|x|\\&= 2\frac{x^2}{|x|}\\&=2\bigg|\frac{x^2}{x}\bigg|\\&=2|x|\end{align*} $$
For the left and right hand limits of $$f'(x)=\frac{x^2}{|x|}+|x|$$ as $x\to 0$, both go to $0$, so $f(x)$ is differentiable at $0$.
Note:For $g(x)=|x|$, $$\begin{align*} g'(x)&=\lim_{h\to 0} \frac{|x+h|-|x|}{h}\\&=\lim_{h\to 0}\frac{\sqrt{(x+h)^2}-\sqrt{x^2}}{h}\\&=\lim_{h\to 0} \frac{(x+h)^2-x^2}{h(\sqrt{(x+h)^2}+\sqrt{x^2})}\\&=\lim_{h\to 0}\frac{x^2+2xh+h^2-x^2}{h(\sqrt{(x+h)^2}+\sqrt{x^2})}\\&= \lim_{h\to 0} \frac{2x+h}{\sqrt{(x+h)^2}+\sqrt{x^2}}\\&= \frac{2x}{2|x|}\\&=\frac{x}{|x|}\end{align*}$$
</s>