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 }
$$
 A: The continuity part is correct, but not the differentiability part. Note that $f(x)=x^2$ is $x\geqslant0$. This shows that $f'(x)=2x$ is $x>0$ and that the right derivative of $f$ at $0$ is $0$. By the same argument, $f'(x)=-2x$ is $x<0$ and the left derivative of $f$ at $0$ is $0$. So, $f$ is differentible in $\Bbb R\setminus\{0\}$ and, since the left and the right derivatives at $0$ are both equal to $0$, $f'(0)=0$. In particular, $f$ is differentiable at $0$ too.
A: Alternatively,

*

*for $x<0$, $f(x)=-x^2$, which is differentiable;


*for $x>0$, $f(x)=x^2$, which is differentiable;


*at $x=0$, $\dfrac{f(h)-f(0)}h=\pm h\to 0$ confirms the function being differentiable.
A differentiable function is also continuous.
A: 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*}$$
