Continuity and derivability of a piece wise f unction Let $f(x)=x^3-9x^2+15x+6$ and 
$$g(x)=
\begin{cases} 
      \min f(t) &\mbox{if } 0\leq t \leq x, 0 \leq x \leq6 \\
      x-18 &\mbox{if }x\geq 6. \\ 
\end{cases}
$$
Then discuss the continuity and derivability of $g(x)$. 
Could someone explain be how to deal with $\min f(t)$ where  $0\leq t \leq x, 0 \leq x \leq6$.

To figure out $\min f(t)$ for $0 \leq t \leq x$, it would help to know when $f(t)$ is decreasing and when it is increasing, so we need to know the derivative. We have:
$$f'(t)=3x^2-18x+15=3(x-5)(x-1)$$
This means $f(t)$ is increasing for $0 < x < 1$, decreasing from $1 < x < 5$ and increasing from $5 < x < 6$.
This means $f(t)$ goes from $f(0)=6$ to $f(1)=13$, so for $x \in [0, 1]$, we have $g(x)=\min f(t)=6$.
Then, we go from $f(1)=13$ to $f(5)=-19$. Somewhere in here, we hit $f(t)=6$ and then keep going down from there. By solving the equation $f(t)=6$ (subtract both sides by $6$, factor $t$ out, use quadratic formula, ignore solutions outside $[1, 5]$), we get $t=\frac{9-\sqrt{21}}{2}$. Thus, for $1 \leq x \leq \frac{9-\sqrt{21}}{2}$, we have that $g(x)=\min f(t)=6$.
Then once we hit $t=\frac{9-\sqrt{21}}{2}$, $f(x)$ goes below $6$ and keeps decreasing, so for $\frac{9-\sqrt{21}}{2} \leq x \leq 5$, we have $\min f(t)=f(x)$. At $x=\frac{9-\sqrt{21}}{2}$, $g(x)$ abruptly changes from $g(x)=6$ to $g(x)=f(x)$, so it is not differentiable at this point, even though it is continuous since $f(\frac{9-\sqrt{21}}{2})=6$.
After that, we go from $f(5)=-19$ to $f(6)=-12$. Here, we are all increasing, so the minimum is still $f(5)=-19$, so for $5 \leq x \leq 6$, we have $g(x)=\min f(t)=-19$. At $f(x)=5$, $g(x)$ again abruptly changes, this time from $g(x)=f(x)$ to $g(x)=-19$, so it is not differentiable at this point, even though it is continuous since $f(5)=-19$.
Then, for $x > 6$, we jump from $g(x)=-19$ to $g(x)=x-18=-12$, so the function has a discontinuity at $x=6$, but is continuous everywhere else.
