Why is the pointwise maximum of two linear functions convex despite its kink?
answer
- the definition never mentions derivatives
- each piece already obeys the chord bound
- bound each one by the larger of the two
- max preserves it, min does not
basics
~20 sConvexity is defined by the chord inequality, which never mentions derivatives. Each linear piece satisfies that inequality, and taking the maximum of two bounds preserves it, so the max is convex. The corner where the two lines cross affects smoothness only.
solid answer
~40 sThe chord definition requires `f(t*x + (1-t)*y) <= t*f(x) + (1-t)*f(y)` and says nothing about derivatives, so a corner is not disqualifying. For `f = max(f1, f2)` with each `f_i` convex, evaluate at a point on the segment: `f_i(t*x + (1-t)*y) <= t*f_i(x) + (1-t)*f_i(y) <= t*f(x) + (1-t)*f(y)` for each `i`, since `f_i <= f` pointwise. Taking the max over `i` on the left gives the chord inequality for `f`. The same two lines of argument work for the pointwise supremum of any family of convex functions, which is why piecewise-linear objectives, norms and support functions are convex. A related object is `log(exp(a) + exp(b))`, which is smooth, convex, and satisfies `max(a, b) <= log(exp(a) + exp(b)) <= max(a, b) + log 2` — a differentiable upper bound on the max.
go deeper
Be ready to say that convexity is defined by the chord inequality, not by having a derivative, and to name max(0, x) as a convex function with a corner.
Explain the two-line proof: bound each piece by its own chord, then by the larger function, and take the maximum on the left to recover the chord inequality.
Show that you certify objectives by construction — recognising a worst-case or piecewise-linear term as a supremum of convex pieces — and that you know the minimum breaks the rule.
Own the tradeoff between a non-smooth convex formulation and a smooth surrogate that sits near it, and be able to justify which one the team should optimise and why.
## Convexity does not require smoothness The definition of a convex function is the chord inequality on a convex domain, ``` f(t*x + (1 - t)*y) <= t*f(x) + (1 - t)*f(y) for all t in [0, 1] ``` No derivative appears anywhere in it. So the presence of a corner in the graph — a point where the slope jumps — is entirely compatible with convexity. Familiar convex functions with corners include `max(0, x)`, the absolute value, and any piecewise-linear function whose slopes increase from left to right. (The converse direction is worth knowing: a convex function on an *open* interval is automatically continuous there. Convexity buys you continuity for free, just not differentiability.) ## The proof that a pointwise max is convex Let `f1, ..., fk` be convex on a common convex domain and define `f(x) = max_i f_i(x)`. Fix `x, y` and `t` in `[0, 1]`, and write `z = t*x + (1 - t)*y`. For each index `i`: ``` f_i(z) <= t*f_i(x) + (1 - t)*f_i(y) (f_i is convex) <= t*f(x) + (1 - t)*f(y) (f_i <= f pointwise, t and 1-t are >= 0) ``` The right-hand side does not depend on `i`, so it also bounds the maximum over `i`, which is `f(z)`. That is exactly the chord inequality for `f`. Two features of the argument matter: the weights `t` and `1 - t` are non-negative, so the inequalities may be multiplied through without flipping; and nothing about the number of functions was used, so the same proof covers the **pointwise supremum of an arbitrary family** of convex functions, as long as the supremum is finite. Specialising to two affine functions `f1(x) = a1 . x + b1` and `f2(x) = a2 . x + b2`: each is convex (affine functions satisfy the chord condition with equality), so their max is convex. Geometrically the graph is two half-lines meeting at a crease that points **downward** — the region above the graph is still a convex set, which is the epigraph view of the same fact. ## Why this rule earns its keep Most convex objectives in practice are assembled, not verified. The three workhorse rules are: - a **non-negative weighted sum** of convex functions is convex; - **composition with an affine map**, `x -> f(A*x + b)`, preserves convexity; - the **pointwise maximum or supremum** of convex functions is convex. The third is the one that generates non-smooth convex objectives: piecewise-linear penalties, the maximum violation across a set of constraints, worst-case objectives of the form `max over scenarios`, and every norm (a norm is the supremum of linear functions over the unit ball of the dual norm). Recognising an objective as a max of convex pieces certifies convexity instantly, where trying to differentiate twice would stall at the kink. ## The minimum is not convex Symmetry is tempting but wrong: the pointwise **minimum** of convex functions is generally not convex. Take `f1(x) = x^2` and `f2(x) = (x - 3)^2` and let `g = min(f1, f2)`. Then `g(0) = 0` and `g(3) = 0`, so the chord between those points sits at height `0`, but `g(1.5) = 2.25 > 0`. The graph rises above its own chord, so `g` is not convex. The failure of the proof above is easy to see: `f_i >= g` gives an inequality in the unhelpful direction. ## Log-sum-exp A closely related function is `lse(a, b) = log(exp(a) + exp(b))`, which is convex and, unlike the max, infinitely differentiable. It brackets the max tightly: ``` max(a, b) <= log(exp(a) + exp(b)) <= max(a, b) + log 2 ``` The lower bound holds because `exp(a) + exp(b) >= exp(max(a, b))`; the upper bound because `exp(a) + exp(b) <= 2*exp(max(a, b))`. With `n` arguments the gap is at most `log n`. So log-sum-exp is a smooth convex surrogate that sits just above the max, which is why it appears wherever a differentiable stand-in for a maximum is wanted. Note the direction of the claim precisely: it is the max that has the kink, and log-sum-exp that smooths it — asserting the reverse is a common slip.
- Does the same argument extend to an infinite family of convex functions?Yes. The proof bounds each member by the same right-hand side, which does not depend on the index, so it survives taking a supremum over any index set, finite or not, provided the supremum is finite. That is how norms and support functions are shown convex: each is a supremum of linear functions over a set.
- Is the pointwise minimum of two convex functions convex?Generally no. With `f1(x) = x^2` and `f2(x) = (x-3)^2`, the minimum is `0` at both `x = 0` and `x = 3` but equals `2.25` at the midpoint `1.5`, so the graph rises above its own chord. The proof for the maximum relies on each member being bounded above by the combined function, and that direction reverses for the minimum.
- How does log(exp(a) + exp(b)) relate to max(a, b)?It is a smooth convex function sandwiched as `max(a, b) <= log(exp(a) + exp(b)) <= max(a, b) + log 2`, with the gap growing only to `log n` for `n` arguments. So it is a differentiable upper bound on the maximum. The maximum is the non-smooth one; log-sum-exp is the smoothing of it, not the other way round.
Picture two straight ramps crossing. Taking the higher of the two at every point traces a valley with a sharp crease at the bottom, and everything above that crease is still a solid, dent-free region.
saying these in an interview costs you the question
- Says a convex function must be differentiable everywhere
- Claims the kink alone makes the function non-convex
- Assumes the minimum of convex functions is convex too
- Calls log-sum-exp non-smooth because the max is
- Proves it only for two functions and stops