• Practice
  • About 15 min
  • 5 practice questions

Differentiability of piecewise, modulus and greatest-integer functions

Decide where a piecewise or modulus function is differentiable, find constants that make it differentiable, count points where it fails, and use the rule for g(x)|x − a|.

If something looks wrong, please tell us.

Exam questions on differentiability almost always feature a piecewise definition or a modulus. They test two habits: checking continuity before looking at slopes, and comparing the left-hand and right-hand derivatives separately. This lesson turns those habits into a short routine and adds two time-saving rules.

The routine at a joining point x = a

  • Continuity: the left-hand value, the right-hand value and f(a) must be equal.
  • Left slope: differentiate the left formula and put x = a.
  • Right slope: differentiate the right formula and put x = a.
  • Differentiable at a exactly when the continuity test passes and the two slopes are equal.

At a joining point: first make the values match (continuity), then make the slopes match (differentiability). Two equations give two unknown constants.

Worked example 1: finding constants

Let f(x) = x² for x ≤ 3 and f(x) = ax + b for x > 3. For f to be differentiable at 3, continuity requires 9 = 3a + b, and the slopes must agree: 2x = 6 on the left, a on the right, so a = 6. Then b = 9 − 18 = −9. The function is x² on the left and 6x − 9 on the right, and the line is tangent to the parabola at (3, 9).

Worked example 2: counting points of failure

Where is f(x) = |x² − 1| not differentiable? Inside the modulus, x² − 1 changes sign at x = 1 and x = −1. Near x = 1, for x slightly less than 1 the function is 1 − x², with slope −2x = −2, and for x slightly more than 1 it is x² − 1 with slope 2. The slopes differ, so there is a corner. By symmetry the same happens at x = −1. There are 2 points of non-differentiability. In general, |h(x)| has corners at the simple zeros of h, where h changes sign with a non-zero slope.

A speed rule for g(x)|x − a|

Let f(x) = g(x)|x − a|, where g is differentiable at a. For h > 0, [f(a + h) − f(a)]/h = g(a + h) → g(a). For h < 0 it equals −g(a + h) → −g(a). The two one-sided derivatives are g(a) and −g(a), which are equal only if g(a) = 0. So f is differentiable at a exactly when g(a) = 0.

Worked example 3: using the rule

The function (x − 1)|x − 1| has g(x) = x − 1 and g(1) = 0, so it is differentiable at 1, with derivative 0 there. The function (x + 2)|x − 1| has g(1) = 3 ≠ 0, so it is not differentiable at 1: the one-sided derivatives are 3 and −3. The function |x − 1| + |x − 2| has corners at both 1 and 2, because at each of these points the other term is smooth and the term with the modulus has a corner.

A function that is differentiable but not smooth

Let f(x) = x² sin(1/x) for x ≠ 0 and f(0) = 0. At 0, [f(h) − f(0)]/h = h sin(1/h). Since |h sin(1/h)| ≤ |h|, the squeeze theorem gives 0, so f′(0) = 0 and f is differentiable at 0. For x ≠ 0, f′(x) = 2x sin(1/x) − cos(1/x), which has no limit as x → 0 because cos(1/x) keeps oscillating. So f′ exists everywhere but is not continuous at 0.

Greatest integer functions

[x] jumps at every integer, so it is not continuous there and cannot be differentiable there. At other points it is constant, so its derivative is 0. A product such as x[x] is likewise discontinuous at every non-zero integer, so check continuity first before you try slopes.

Key takeaways: test continuity first, then compare the left and right slopes. Two conditions give two constants. |h(x)| has a corner at each simple zero of h. The function g(x)|x − a| is differentiable at a only when g(a) = 0. Differentiable does not mean the derivative is continuous.

Check your understanding

  1. 1. Let f(x) = x² for x ≤ 3 and f(x) = ax + b for x > 3. For f to be differentiable at 3, which pair (a, b) works?

    1. a = 6, b = 9
    2. a = 3, b = 0
    3. a = 6, b = −9
    4. a = 9, b = −18
    Show answer

    Answer: C. Continuity: 9 = 3a + b. Slopes: 2x = 6 at x = 3, so a = 6. Then b = 9 − 18 = −9.

  2. 2. At how many points is f(x) = |x² − 1| not differentiable?

    1. 2
    2. 1
    3. 0
    4. 3
    Show answer

    Answer: A. The expression x² − 1 changes sign at x = 1 and x = −1 with non-zero slope there, so |x² − 1| has a corner at each of these two points.

  3. 3. At x = 1, which function is differentiable?

    1. (x + 2)|x − 1|
    2. |x − 1|
    3. (x + 1)|x − 1|
    4. (x − 1)|x − 1|
    Show answer

    Answer: D. g(x)|x − a| is differentiable at a exactly when g(a) = 0. Only (x − 1)|x − 1| has g(1) = 0; the others have g(1) = 3, 1 and 2 respectively.

  4. 4. Let f(x) = x² sin(1/x) for x ≠ 0 and f(0) = 0. What is f′(0)?

    1. 1
    2. 0
    3. −1
    4. It does not exist
    Show answer

    Answer: B. [f(h) − f(0)]/h = h sin(1/h), and |h sin(1/h)| ≤ |h| → 0. So f′(0) = 0.

  5. 5. For which x is the function f(x) = [x] (the greatest integer function) differentiable?

    1. Every x that is not an integer
    2. Every real number x, without exception
    3. Only at the single point x = 0 itself
    4. No real number x at all
    Show answer

    Answer: A. At an integer, [x] jumps and is not continuous, so it cannot be differentiable there. Between integers it is constant, so its derivative exists and equals 0.

Privacy · Terms · Refunds · Delivery