[Math] How to make a piecewise function differentiable

derivatives

I have the following question:

Suppose $$f(x) = \left\{\begin{array}{cc}x^2 & \text{if }x\leq 2 \\ mx+b& \text{if }x>2\end{array}\right.$$

If $f$ is differentiable everywhere, then what are the values of $m$ and $b$?

How exactly would I be able to get the values to be differentiable? I know that the point at 2 has to exist and that it has to be continuous and connect to the other function to work. How exactly do I get the exact values for "m" and "b" though?

Best Answer

$f$ has to satisfy $$ \lim_{x\to 2+}f(x)=f(2),\quad \lim_{x\to 2- }=\frac{f(x)-f(2)}{x-2}=\lim_{x\to 2+ }=\frac{f(x)-f(2)}{x-2}, $$ i.e. $$ 2m+b=4,\quad m=4 \Rightarrow m=4,b=-4. $$