Skip to content
Glacius
OptimizationConcept reference

Subgradients

A convex subgradient defines a global linear lower bound; absolute value has every slope in [−1,1] at zero.

On this page 8 sections
  1. Overview
  2. Understand the idea
  3. For |x|, the slope is −1 when x<0 and +1 when x>0
  4. Checking z=0 alone cannot reject any proposed slope at the origin: both sides equal zero
  5. This supporting-line view explains how optimization can work with a nonsmooth L1 penalty
  6. Key takeaway
  7. Sources & further reading
  8. Concept connections

01Understand the idea#

Ordinary derivatives require one local slope, but penalties such as absolute value have a corner at zero. Convex subgradients extend slope information to that case. A valid subgradient gives a line touching the function at the current point and staying below it everywhere.

A convex subgradient gives a supporting line below the function. At x, slope g must satisfy this for every z:

f(z)f(x)+g(zx)\begin{aligned}f(z)&\ge f(x)\\&\quad+g(z-x)\end{aligned}

At a smooth point it is the derivative. At a kink there can be an interval of valid slopes.

For |x| at zero, slopes from −1 through 1 all work. Slope 0.25 is valid; slope 3 fails at z=1 because 1<3.

The mint V is |x|. The gold supporting line with slope .25 stays below it. The dashed comparison with slope 3 passes through (1,3), above |1|=1, and so fails the global supporting-line inequality. At zero the complete allowed slope interval is [−1,1].The mint V is |x|. The gold supporting line with slope .25 stays below it. The dashed comparison with slope 3 passes through (1,3), above |1|=1, and so fails the global supporting-line inequality. At zero the complete allowed slope interval is [−1,1].
Figure 1The mint V is |x|. The gold supporting line with slope .25 stays below it. The dashed comparison with slope 3 passes through (1,3), above |1|=1, and so fails the global supporting-line inequality. At zero the complete allowed slope interval is [−1,1].
Link to this figure ↗Download SVGDownload PNG

At zero, f(x)=xf(x)=|x| has right slope 1 and left slope 1-1. A line gzgz stays below z|z| for every zz exactly when 1g1-1\le g\le1. If g=3g=3, try z=1z=1: the line gives 3 above the function’s 1, so that proposed slope fails.

Check your reasoning

f(x)=|x|. At x=0, which slope is a valid subgradient?

  1. A2
  2. B-0.5
  3. C-2
Show answer and explanation
-0.5

At zero use [−1,1]; away from zero use the sign of x.

02For |x|, the slope is −1 when x<0 and +1 when x>0#

For |x|, the slope is −1 when x<0 and +1 when x>0. At zero the full set is [−1,1].

For a|x−c| with a>0, the kink moves to c and its slope interval becomes [−a,a].

Check your reasoning

f(x)=5|x−2|. Give the full subdifferential at x=2.

  1. A[5,5][-5,5]
  2. B[10,10][-10,10]
  3. C[4,4][-4,4]
Show answer and explanation
[5,5][-5,5]

The kink is at 2; scale both slope endpoints by 5.

03Checking z=0 alone cannot reject any proposed slope at the origin: both sides equal zero#

Checking z=0 alone cannot reject any proposed slope at the origin: both sides equal zero. Use a point that can violate the global supporting-line condition.

A slope inside [−1,1] needs no repair for |x| at zero. Nondifferentiability does not mean there is no useful first-order information.

Check your reasoning

At x=0 for |x|, draft slope g=1.5. Which test disproves |z|≥gz for all z?

  1. Az=−1
  2. BNo counterexample exists.
  3. Cz=1
Show answer and explanation
z=1

At z=1, 1<1.5.

04This supporting-line view explains how optimization can work with a nonsmooth L1 penalty#

This supporting-line view explains how optimization can work with a nonsmooth L1 penalty. A single point on the line does not certify it; the condition must hold everywhere. At a smooth point of a convex function, the ordinary derivative supplies its subgradient.

Key takeaway

Use the sign away from zero and the full allowed interval at zero; test a claimed slope with the supporting-line inequality.

  • Identify valid subgradients of absolute value, including at zero.

Sources & further reading

  1. [1]
    Boyd, Duchi, Pilanci & Vandenberghe, Subgradients §1Boyd, Duchi, Pilanci & Vandenberghe, Subgradients §1 · Article

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Subgradients.” Math behind ML. /learn/o-subgradient