Alternative to Lagrange multiplier to find min distance

164 Views Asked by At

I'm using SymPy to find the minimum distance of functions to the origin.

To do this I work with Lagrange multipliers, but I don't know how to deal with functions for which their derivatives are not zero at the minimum.

Any alternative I can use, that always work or that works in that case?

EDIT: also the domain of the functions I have do not contain $\vec x = \vec 0$

1

There are 1 best solutions below

2
On

If you really do have a single-variable function, there’s no particularly good reason that I can see to use the method of Lagrange multipliers for this. The expression for the distance of a point from the origin is the also a function of a single variable, so you might as well just differentiate that and look for critical points. You end up with the same equation that you would eventually arrive at via Lagrange multipliers, but with much less work.

One important thing that you do have to account for is that the minimum might occur at the end points of the function’s domain, where you won’t necessarily have a critical point. A case in point: Your example function is only defined on the interval $[1,3/2)$. For $x=3/2$ the denominator is zero, while for other values of $x$ outside of this interval the quantity under the radical is negative. Working through differentiating $x^2-f(x)^2$ (might as well use the square of the distance, as usual), we can eventually find that this vanishes for $x=0$ and $4x^2-13x+12=0$. The former is outside of the domain of $f$ and the latter has no real roots, so the distance function has no critical points in the interior of $f$’s domain and the only remaining candidate for a minimal-distance point is $x=1$. We have $f(1)=0$ therefore the distance to the origin from there is $1$. You can verify in various ways that this is indeed the minimal distance. A simple way is to examine the value of the derivative of the distance function there: it’s positive, so it increases for increasing $x$ near $1$. (This seems a bit of a cheat, but can be justified more rigorously.)