The interview problem

Practice prompt

Solve a simple constrained optimization problem and explain complementarity.

Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.

1. Scope and worked approach

Minimize (x−3)^2 subject to x≤1. Write g(x)=x−1≤0 and L=(x−3)^2+lambda(x−1). KKT requires stationarity, primal feasibility, lambda≥0 and lambda g(x)=0. For this convex differentiable problem with a strictly feasible point, the conditions characterize the optimum. In a nonconvex problem they need not establish a global optimum.

2. Trace the design or derivation

Write constraint sign
  → form Lagrangian
  → solve stationarity
  → check feasibility and complementarity

Relaxing the bound from 1 to 1+delta changes the optimal objective to (2−delta)² for small positive delta. Its derivative at zero is −4, matching the multiplier's local sensitivity interpretation. This interpretation is local and depends on regularity; it is not a universal global exchange rate.

3. Calculate the example

The unconstrained minimum x=3 is infeasible. At x=1, stationarity gives 2(1−3)+lambda=0, so lambda=4. Feasibility and complementarity hold, and objective value is 4.

4. Failure cases and trade-offs

Changing constraint sign without changing multiplier convention reverses the conditions. A zero multiplier does not always imply a strictly inactive constraint in degenerate cases. Numerical solvers use tolerances, so inspect residuals rather than exact equality checks on floating-point outputs.

5. Validation, follow-ups and self-review

Compare objective values at x=0 and x=1 and check all four conditions. Follow-up: how would x≤4 change the active set? Self-review: distinguish necessary conditions, convex sufficiency and multiplier sign.

Sources and related practice

Technical reference: see.stanford.edu — KKT optimality and convex sufficiency.

Source publication/update: Not established. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.

Continue with Gradient descent and training diagnostics; Use curvature to reason about optimization.

Continue your preparation

Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.