You can use Lagrange multipliers to find constrained optima. To find extreme values of f (x, y) subject to a constraint g(x, y) = k, it is sufficient to find all values of x, y, and λ such that