Skip to content
DeepForgeby svx
All problems
HardCalculusca-273

Lagrange Multipliers with Two Constraints

Problem

Minimize f(x, y, z) = x^2 + y^2 + z^2 subject to x + y + z = s1 and x - y = s2 using two Lagrange multipliers.

The optimum is at x = s1/3 + s2/2, y = s1/3 - s2/2, z = s1/3, and the minimum value is s1^2/3 + s2^2/2. Given s1 and s2, return the minimum value.

Hint

With two constraints the gradient is a combination of the two constraint normals.

Test cases

case 1
in: [3,0]
expected: 3
case 2
in: [0,2]
expected: 2
case 3
in: [3,2]
expected: 5
case 4
in: [0,0]
expected: 0
Starter codePython
def lagrange_two_constraints(s1, s2):
    # Your code here
    pass

4 test cases · run your code against them in the editor