I would like to get the derivative of this function: $ f(x)=(x-a)^2(x-b)^2 $ and $f(x) = \frac{1}{e}$ I want to get the derivative of this function: 
$$ f(x)=(x-a)^2(x-b)^2 $$
for $x ∈< a, b >$, $$f(x) = \frac{1}{e}$$ for all other $x$.
Now I know the result is:
$$ f'(x) = 2(x − a)(x − b)(2x − a − b)$$ for $$x ∈ (a, b);$$ and$$ f'_{+}(a) = f'_{−}(a) = f'_{+}(b) = f'_{−}(b) = 0; f'(x) = 0 $$
for
  $$x ∈ (−∞, a) ∪ (b, ∞) $$
But I don't know how to get to it. Any help would be greatly appreciated.
 A: In order that the function is differentiable at $a$ and $b$, it must be continuous. It is not, because
$$
\lim_{x\to a^+}f(x)=0,
\qquad
\lim_{x\to a^-}f(x)=\frac{1}{e}
$$
Similarly at $b$.
Thus the function can be differentiable only at points distinct from $a$ and $b$ and
$$
f'(x)=\begin{cases}
0 & \text{if $x<a$}\\[3px]
2(x-a)(x-b)(2x-a-b)& \text{if $a<x<b$}\\[3px]
0 & \text{if $x>b$}
\end{cases}
$$
A: For all $ x∈(a,b)$
$$f^{ \prime  }\left( a+ \right) =\lim _{ x\rightarrow a+ }{ \frac { (x-a)^{ 2 }(x-b)^{ 2 }-(a-a)^{ 2 }(a-b)^{ 2 } }{ x-a }  } =\lim _{ x\rightarrow a+ }{ (x-a)(x-b)^{ 2 } } =0\\ \\ \\ f^{ \prime  }\left( b- \right) =\lim _{ x\rightarrow b- }{ \frac { (x-a)^{ 2 }(x-b)^{ 2 }-(b-a)^{ 2 }(b-b)^{ 2 } }{ x-b }  } =\lim _{ x\rightarrow b- }{ (x-a)^{ 2 }(x-b) } =0$$
and for  all $x∈(−∞,a)∪(b,∞)$
$$\\ f^{ \prime  }\left( a- \right) =\lim _{ x\rightarrow a- }{ \frac { \frac { 1 }{ e } -\frac { 1 }{ e }  }{ x-a } =0 } \\ f^{ \prime  }\left( b+ \right) =\lim _{ x\rightarrow a- }{ \frac { \frac { 1 }{ e } -\frac { 1 }{ e }  }{ x-b } =0 } \\ \\ \\ $$
A: For $x\in (a,b)$, just use product rule on the function $(x-a)^2(x-b)^2$.
For $x\in (-\infty,a)\cup (b,\infty)$, taking the derivative of $f(x)=\frac{1}{e}$ gives you zero.
For the two points $a,b$, I think what you really want is $f'(a^+)=f'(a^-)=0$ and $f'(b^+)=f'(b^-)=0$. 
To find $f'(a^+)$, you plug $a$ into the derivative for the part $x\in(a,b)$ (so that $x$ approaches $a$ from the positive direction). To get $f'(a^-)$, you plug $a$ into the derivative for $x\in(-\infty,a)$. That gives you derivative when $x$ approaches $a$ from the negative direction. 
You can apply the same idea to $b$.
