Lab 3: A Lagrange Multiplier by Hand

DATA 442/642 · Week 3 · PDF

One equality constraint, stationary points, and a contour picture.

Work in a Jupyter notebook. Number the exercises. Do notes 3.1 through 3.3 first. You will need numpy and matplotlib.

The original assignment PDF is lab-3-assignment.pdf.

When you are done: File → Download as → HTML, then upload the HTML on Canvas.


1. One equality, by hand (3 points)

minθJ(θ)=5θ12+3θ22subject tog(θ)=4θ1+2θ2−12=0.
  1. Write the Lagrangian ℒ(θ,λ)=J(θ)+λg(θ).
  2. Set ∇θℒ=0 and g=0. Solve for θ1, θ2, and λ. Show the algebra in the notebook (markdown or comments), then check the numbers in code.
  3. Say what θ and λ mean for a model whose parameters must satisfy a computational budget written as g=0.

2. Picture (2 points)

Contour plot of J in the (θ1,θ2) plane. Draw the line g=0. Mark the constrained minimizer. The unconstrained min is the origin; your star should not be there.