TITLE: Construct a function which is continuous in $[1,5]$ but not differentiable at $2, 3, 4$
QUESTION [90 upvotes]: Construct a function which is continuous in $[1,5]$ but not differentiable at $2, 3, 4$.

This question is just after the definition of differentiation and the theorem that if $f$ is finitely derivable at $c$, then $f$ is also continuous at $c$. Please help, my textbook does not have the answer.

REPLY [913 votes]: $$\ \ \ \ \mathsf{W}\ \ \ \ $$

REPLY [34 votes]: How about $f(x) = \max(\sin(n\pi x),0)$ or perhaps $g(x) = |\sin(n\pi x)|$?