FREE4/4+0ACC--
← Gradient Lab

Lagrange Optimizer - Constrained Optimization Practice

CALC6G/02 LAGRANGE OPTIMIZER
LOADING

Loading a fresh constraint…

GENERATING A FRESH ROUND

About Lagrange Optimizer

Maximize xy on a budget line ax + by = k by solving the Lagrange condition ∇f = λ∇g for x* with nothing but the algebra - there is no live readout to chase.

Each round generates a fresh problem: maximize f(x, y) = xy subject to ax + by = k with x, y ≥ 0, where a and b are random integers from 1 to 4 and k is a random integer from 6 to 21. You are asked for x* at the optimum and must type the number - there is no live objective readout to converge on visually.

The hint on screen sets up the method: ∇f = (y, x) and ∇g = (a, b), so the Lagrange condition ∇f = λ∇g gives y = λa and x = λb. Substituting both into the constraint yields a(λb) + b(λa) = k, so λ = k/(2ab), and then x* = λb and y* = λa.

After you check, the reveal walks the full solution: λ, x*, y*, a numerical check that ax* + by* ≈ k, and the maximum value of xy. Press next round for a new (a, b, k).

Why quant interviews test this

Constrained optimization is the backbone of the quant-research canon: mean-variance portfolios, maximum likelihood under constraints, and utility maximization are all Lagrange computations, and interviews regularly ask a small closed-form instance exactly like this game's - maximize a product or a log-sum under a linear budget.

The two follow-ups to prepare: interpret λ as a shadow price (the derivative of the optimal value with respect to the constraint level), and reproduce the answer by a second route such as AM-GM or direct substitution of y = (k - ax)/b followed by one-variable calculus. Interviewers use the second route to separate memorized formulas from understanding.

The Lagrange Optimizer guide covers how scoring works, the strategy that wins, a worked example and the mistakes most players make.

More Calculus & Linear Algebra games