Which of these functions are convex, and why: (a) ∥x∥2; (b) log⁡(1+ex); (c) x3 on R; (d) f(x,y)=xy; (e) the hinge loss max⁡(0, 1−y w⊤x) as a function of w?

Linear algebra and optimisation, Convexity
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can pick the right convexity test for each kind of function: the definition, the second derivative, the Hessian, or the composition rules.

Key idea

f is convex if f(λa+(1−λ)b)≤λf(a)+(1−λ)f(b) for all a,b and λ∈[0,1]: the chord lies above the graph. For smooth functions, check f′′≥0, or a PSD (positive semidefinite) Hessian in several variables. For norms, use the triangle inequality. For piecewise functions, use “a maximum of convex functions is convex”.

Steps

  1. (a) Convex. By the triangle inequality and scaling, ∥λa+(1−λ)b∥≤λ∥a∥+(1−λ)∥b∥, which is exactly the definition. The norm has no derivative at 0, so the Hessian test cannot be used there.
  2. (b) Convex. f′(x)=σ(x), where σ(x)=1/(1+e−x) is the sigmoid, and f′′(x)=σ(x)(1−σ(x))>0.
  3. (c) Not convex. f′′(x)=6x, which is negative for x<0. It is convex only on [0,∞).
  4. (d) Not convex. The Hessian is (0110), with eigenvalues +1 and −1. One negative eigenvalue means it is not PSD; the origin is a saddle. Along the line (t,−t), f=−t2 curves downwards.
  5. (e) Convex. 1−y w⊤x is linear in w, the constant 0 is linear, and the maximum of convex functions is convex. At the kink, use subgradients instead of a derivative.

Common mistakes

How long your answer should be

One or two lines per function; about 3 minutes.

Read this

Previous in Linear algebra and optimisation: What are ∇x (x⊤Ax) for a square matrix A and ∇x ∥Ax−b∥2, and how do you derive them?
Next in Linear algebra and optimisation: How is the SVD of a matrix A related to the eigendecomposition of A⊤A? What are the singular values of A=(3045), and what is the error of its best rank-1 approximation?