Notes on Lagrange multiplier: What is the shortest distance from the origin to the ellipse 2(Y-1)2 + 3(X-3)2 -9=0 ? Let g(X,Y) = 2(Y-1)2 + 3(X-3)2 -12 Points at distance r from the origin satisfy X2 + Y2 = r2 so the squared distance is a function f(X,Y) that plots as a set of concentric circles as the squared distance increases. Its derivatives are df/dx=2X and df/dy=2Y. Expanding r until the circle and ellipse meet gives us the minimum distance desired and the meeting point is such that the gradients (the vectors of partial derivatives) must be proportional which means that (df/dx, df/dy) = (dg/dx, dg/dy) so if we write down f(X,Y) – g(X,Y) and set all of its derivatives to 0, we have the solution we want. In particular the partial with respect to X gives (df/dx)= – (dg/dx) and the similarly for y and thus (df/dx, df/dy) = (dg/dx, dg/dy). This means that (df/dx)/(df/dy) = (dg/dx)/( dg/dy) = (dg/dx)/(dg/dy) = (dy/dx). Because dy/dx = (df/dx)/(df/dy) this proportionality means that dy/dx is the same ratio for both curves, that is, dy/dx is the slope for both the circle and the ellipse at the point of contact. This follows from the chain rule wherein df/dx = (df/dy)(dy/dx).