I'm given the following function
$$f(x)= \begin{cases} \left(x-a\right)^2\left(x-b\right)^2\;,\quad x \in[a;b]\\ 0\;,\qquad\qquad\qquad\;\; x \notin[a;b] \end{cases}$$
I tried finding the derivative by using the definition, but I couldn't. I am not very familiar with the idea of taking the derivative of a piecewise function, that's why I'm stuck and don't know what to do. I would be great help for me if you could show how to take the derivatives of this kinds of functions or give some hints. Thank you very much.