Find the shortest distance between the curve $y^2=x$ to the line $y=x+1$.
Im not sure how to attack a problem like this.
Find the shortest distance between the curve $y^2=x$ to the line $y=x+1$.
Im not sure how to attack a problem like this.
On
With Lagrange multipliers: you want minimize $$(x-u)^2 + (y-v)^2$$ with the restrictions $$y^2 - x = 0,\qquad u - v + 1 = 0.$$ The Lagrange system is the two previous equations plus: $$2(x - u) = -\lambda,$$ $$2(y - v) = 2\mu y,$$ $$-2(x - u) = \mu,$$ $$-2(y - v) = \mu.$$ This is an homogeneous system and we want a solution $\ne(0,0,0,0)$ (why?), so the matrix of the system must be zero...
On
Let the parabola and the line be parameterized as follows
$$\mathcal P := \{ (t_1^2, t_1) \mid t_1 \in \mathbb R \} \qquad \qquad \qquad \mathcal L := \{ (t_2, t_2+1) \mid t_2 \in \mathbb R \}$$
The squared distance between $\mathcal P$ and $\mathcal L$ is given by the minimum of the quartic objective function
$$f (t_1, t_2) := \left( t_1^2 - t_2 \right)^2 + \left( t_1 - t_2 - 1 \right)^2$$
Differentiating $f$ with respect to $t_1$ and $t_2$ and finding where the partial derivatives vanish, we obtain a system of two polynomial equations
$$\begin{array}{rl} 4 t_{1} \left( t_{1}^{2} - t_{2} \right) + 2 t_{1} - 2 t_{2} - 2 &= 0\\ - 2 t_{1}^{2} - 2 t_{1} + 4 t_{2} + 2 &= 0\end{array}$$
whose solution is
$$(t_1, t_2) = \left( \frac 12, -\frac 18 \right)$$
Thus, the distance between the parabola and the line is
$$\sqrt{\left( \left( \frac 12 \right)^2 + \frac 18 \right)^2 + \left( \frac 12 + \frac 18 - 1 \right)^2} = \sqrt{\frac{9}{32}} = \color{blue}{\frac{3}{4 \sqrt{2}}}$$
>>> from sympy import *
>>> t1, t2 = symbols('t1 t2')
>>> squareddistance = (t1**2 - t2)**2 + (t1 - t2 - 1)**2
>>> solve([diff(squareddistance, t1), diff(squareddistance, t2)], t1, t2)
[(1/2, -1/8), (1/2 - sqrt(3)*I/2, -1/2 - sqrt(3)*I/2), (1/2 + sqrt(3)*I/2, -1/2 + sqrt(3)*I/2)]
Thus, the unique real solution is (1/2, -1/8).
Let $(t^2,t)$ be a point on $y^2=x$. Its distance to the line $x-y+1=0$ is
$$\left|\frac{t^2-t+1}{\sqrt{(1)^2+(-1)^2}}\right|=\frac{(t-\frac{1}{2})^2+\frac{3}{4}}{\sqrt{2}}$$
So the shortest distance is $\frac{3}{4\sqrt{2}}$.