Derivatives of function defined by cases I have the following problem that I'm not sure how to tackle. For function $f$, find values for $a$ and $b$ such that $f'(3)$ exists. 
The function is defined as: 
$$ 
f(x)=
\begin{cases}
\hfill x^2-4x+8 & \text{if $x \leq 3$} \\
ax+b & \text{if $x \gt 3$} \\
\end{cases}
$$
So I'm a bit at a loss here. Both cases of the function are polynomials, so I would assume that they are always derivable, and therefore $f'(3)$ would exist, but I'm not sure how to tackle it. Should I derive both equations and then use the results to create a lineal system of equations? How would you recommend me to proceed?
Also, I'm thinking that maybe $f(x)$ is not continuous in $f(3)$ because the limit approaching by the right might be different from the limit approaching from the left. Does it mean it is not derivable and thus $f'(3)$ actually does not exist?
 A: Continuous piecewise functions composed of differentiable functions are not always differentiable. For example, consider the absolute value function:
$$
|x| =
\begin{cases}
x  & \text{if $x \ge 0$} \\
-x & \text{if $x < 0$}
\end{cases}
$$

Despite being composed of differentiable functions, the function $f(x) = |x|$ is not differentiable at $x = 0$. Taking the limit from the positive side would indicate the slope is $1$, but taking the limit from the negative side would indicate the slope is $-1$.
For most values of $a$ and $b$, your function will look like this (neither continuous nor differentiable).

When $x^2-4x+8 = ax+b$ at the point $x = 3$, this function will become continuous, but still not necessarily differentiable:

For the function to become differentiable, the functions $f(x)=x^2-4x+8$ and $g(x)=ax+b$ and their derivatives $f'(x)=2x-4$ and $g'(x)=a$ must be equal at the point $x = 3$.
You should be able to solve it from there.
A: Hint. As you mentioned, we don’t know $f(x)$ is continuous that’s why we’re trying to find $a$ and $b$ such that the derivative exists at 3. From this we first need the function to be continuous (a condition for differentiability) and we need the limits from the left and right of the derivative to be the same at 3 so that $f’(3)$ exists
