# Constrained optimization : Contour lines and Lagrange's multiplier

Basically the core of Lagrange's multiplier says that the solution to a constrained optimization occurs when the contour line of the function being maximized/minimized is tangential to the constraint curve.

I am not able to convince myself of above statement.

Consider below diagram wherein 'f' is some function being maximized/minimized and g(x,y) is the constraint. the contour lines of f and g(x,y) are plotted. Clearly the contour line which corresponds to local maximum of f is not tangential to g i.e. the gradient vector of f and g don't align at the intersections of f=5 and g.

I am not looking for a rigorous proof or something, just want to get a basic understanding of why gradient of f and g should point in same direction at the local maxima/minima of f?

If $f=5$ is a maximum of $f$, then the gradient of $f$ vanishes on this curve. Therefore, it does not make sense to ask whether it aligns with anything. Or you can say that the gradients are still proportional, but the proportionality factor (the Lagrange multiplier) happens to be zero.
Just take your $g$ and the functions $f=x^2$ or $f=(x-10)^2$ to see things at work.