For a single weight w and a number z, solve min⁡w12(w−z)2+λ∣w∣ and min⁡w12(w−z)2+λ2w2. Why does this show that L1 regularisation gives sparse solutions and L2 does not?

Foundations, Regularisation
Level L3 Intermediate. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you can back up the “diamond touches the axis” picture with a calculation, using subgradients where ∣w∣ has a corner.

Key idea

L1 gives soft-thresholding, w∗=sign⁡(z)max⁡(∣z∣−λ,0), which is exactly zero for every ∣z∣≤λ. L2 gives proportional shrinkage, w∗=z/(1+λ), which is zero only when z=0. “Sparse” means many weights are exactly zero.

Steps

  1. Explain the set-up. z is where the weight would be with no penalty, and λ>0 is the penalty strength. With X⊤X=I (uncorrelated, unit-scale features), lasso and ridge regression split into exactly this 1D problem for each weight.
  2. L2. Differentiate and set to zero: w−z+λw=0, so w∗=z1+λ. Every weight shrinks by the same factor, and none becomes exactly zero.
  3. L1, away from zero. If w>0, the derivative is w−z+λ=0, so w=z−λ; this is only valid when z>λ. If w<0, then w=z+λ, valid only when z<−λ.
  4. L1, at zero. ∣w∣ has a corner at 0, so it has no derivative there. Its subgradient (the set of slopes of lines touching ∣w∣ from below at 0) is [−1,1]. The optimality condition 0∈−z+λ[−1,1] holds exactly when ∣z∣≤λ. So w∗=0 for the whole interval ∣z∣≤λ.
  5. Combine the cases: w∗=sign⁡(z)max⁡(∣z∣−λ,0). Small values of z are set exactly to zero; this is why the lasso selects features.
  6. Add the picture. Write the problem as “minimise the loss subject to ∥w∥1≤t”. The L1 ball is a diamond with corners on the axes, and the oval contours of the loss usually first touch it at a corner, where some weights are zero. The L2 ball is round and has no corners.

Common mistakes

How long your answer should be

Half a page: the two 1D solutions plus the diamond-and-circle sketch.

Last checked on 4 December 2026.

Read this

Previous in Foundations: How do you derive the bias–variance decomposition of the expected squared error E[(y−f^(x))2], where f^ is the model fitted to a random training set?
Next in Foundations: Why is the predictor that minimises the expected squared loss the conditional mean E[Y∣X=x], and why is the classifier that minimises the expected 0-1 loss arg⁡max⁡kP(Y=k∣X=x)?