Prove that the following function is differentiable at $x=\frac{\pi}{4}$:
$$f(x) = \begin{cases} -cosx + C_1, & \text{x $\lt \frac{\pi}{4}$ } \\ sinx -\sqrt2 + C_1, & \text{x $\ge \frac{\pi}{4}$ } \end{cases}$$
$C_1 \in \mathbb{R}$
I tried to solve it using definition of sided derivatives but got stuck on the algebra of calculating limits. I would appreciate if anyone could show me how it should be done. Thanks
For $x\in \mathbb{R}\setminus\{\frac{\pi}{4}\}$, it is clear that $f$ is continuous and differentiable.
You have to prove, then that $$\lim_{x\rightarrow \frac{\pi}{4}} \frac{f(x)-f(\frac{\pi}{4})}{x-\frac{\pi}{4}}$$ exists and is finite.
From the geometry of this problem, it is convenient to divide in two parts the work : prove that $$\lim_{x\rightarrow \frac{\pi}{4}^+} \frac{f(x)-f(\frac{\pi}{4})}{x-\frac{\pi}{4}} \qquad \text{and} \qquad \lim_{x\rightarrow \frac{\pi}{4}^-} \frac{f(x)-f(\frac{\pi}{4})}{x-\frac{\pi}{4}}$$ exists and are equal.
For the first one : $$\lim_{x\rightarrow \frac{\pi}{4}^+} \frac{\frac{\sqrt{2}}{2}-\cos(x)}{x-\frac{\pi}{4}}=\lim_{x\rightarrow \frac{\pi}{4}^+} \frac{\cos(\frac{\pi}{4})-\cos(x)}{x-\frac{\pi}{4}} =-(\cos')(\frac{\pi}{4})=\sin(\frac{\pi}{4})=\frac{\sqrt{2}}{2}$$
Same method for the second one.
It is differentiable.