Consider the function .
When x < −1, g(x) = −2x which being a polynomial function is continuous and differentiable.
When −1 ≤ x < 1, g(x) = 2 which being a constant function is continuous and differentiable.
When x ≥ 1, g(x) = 2x which being a polynomial function is continuous and differentiable.
Let us check the continuity and differentiability of g(x) at x = −1 and x = 1.
At x = −1,
LHL =
RHL =
Since , so the function g(x) is continuous at x = −1.
At x = 1,
LHL =
RHL =
Since , so the function g(x) is continuous at x = 1.
Thus, the function g(x) is continuous everywhere i.e. for all x ∈ R.
Now,
And
So, g(x) is not differentiable at x = −1.
Also,
And
So, g(x) is not differentiable at x = 1.
Thus, the function g(x) is differentiable everywhere except at x = −1 and x = 1.
An example of a function which is everywhere continuous but fails to be differentiable exactly at two points is .