Find the point on the curve $x^2 - z^2 = 1$ closest to the origin.
This is an optimization problem with a constraint — i.e. find the minimum of the distance $D$ of a point in the x-z plane from the origin ($x^2 + x^2 = D^2$) given the constraint above.
When solving for D as a function of x/z in a system of equations:
If we have the system of equations:
$$x^2 + z^2 = D^2$$
$$x^2 - z^2 = 1$$
We should be able to add or subtract these equations to eliminate variables:
Add: $2x^2 = D^2 + 1 \rightarrow D^2 = 2x^2 - 1$
Subtract $2z^2 = D^2 - 1 \rightarrow D^2 = 2z^2 + 1$
Here's my question:
If we treat $D$ as a constant, we can just take the derivative of both sides with respect to the relevant variables, and we get the correct answers:
Add: $\frac{d}{dx}(D^2 = 2x^2 - 1) \rightarrow 0 = 4x \rightarrow \boxed{x=0} \implies \boxed{z=\pm i}$
Subtract: $\frac{d}{dz}(D^2 = 2z^2 - 1) \rightarrow 0 = 4z \rightarrow \boxed{z=0} \implies \boxed{z=\pm 1}$
However, $D$ isn't really "constant" is it? It's a function of x and/or z? In fact, isn't the whole point of this optimization problem to find the minimum value of D, given changes to x or z?
If we treat d as dependent on the variables, we get:
Add: $\frac{d}{dx}(D^2 = 2x^2 - 1) = 2D\frac{dD}{dx} = 4x \rightarrow \frac{dD}{dx}=\frac{2x}{D}$
and
Subtract: Add: $\frac{d}{dz}(D^2 = 2x^2 - 1) = 2D\frac{dD}{dz} = 4z \rightarrow \frac{dD}{dx}=\frac{2z}{D}$
I know that this way of thinking is flawed, because it doesn't produce sensible answers, I'm just curious as to what the reason is that $D$ is treated as a constant.
The curve is an hyperbola in the plane $xz$ and its closest points to the origin are its vertices, which are $(1,0,0)$ and $(-1,0,0)$. To find them analytically, as an exercise, consider the distance function
$$D(x,z)=x^2+z^2$$
with the constraint $x^2-z^2=1$. Using Lagrange multipliers consider the function
$$f(x,z,\lambda)=x^2+z^2+\lambda(x^2-z^2-1)$$
We have
$$\partial f_x=2x+2\lambda x=0$$ $$\partial f_z=2z-2\lambda z=0$$ $$\partial f_{\lambda}=x^2-z^2-1=0$$
Solve the first equations wrt $\lambda$ to get $\lambda=-1$ and plug this value in the second to get $z=0$. Plugging $z=0$ into the third we get the two solutions $x=\pm 1$ as stated from the beginning.
Verify that they are minimum plugging their value in $D(x,z)$ which gives $D=1$.