I want to find the equation of the curve that minimizes the distance between two points $P \equiv (x_1,y_1)$ and $Q \equiv (x_2,y_2)$. Thus, with the curve $\gamma(x)=(t,y(x))$, we have that the distance is the integral between $x_1$ and $x_2$ of $||\gamma'(x)||$ which is: $$ d(P,Q) = \int_{x_1}^{x_2} \sqrt{1+y'(x)^2} \: dx $$ Then, we just need to apply the Euler equation $\frac{\partial f}{\partial y} - \frac{d}{dx}(\frac{\partial f}{\partial y'})=0$, with $f(x,y,y')=\sqrt{1+y'(x)^2}$.
My problem comes when doing the derivatives $$ \frac{\partial f}{\partial y} = \frac{(1+y'(x)^2)^{\frac{1}{2}-1}}{2} \cdot \frac{\partial y'}{\partial y} \stackrel{!!}{=} \frac{1}{2\sqrt{1+y'(x)^2}} \cdot 0=0 $$ But $\frac{\partial y'}{\partial y} \stackrel{!!}{=} 0$ because $y$ and $y'$ are independent. The other part is $$ \frac{\partial f}{\partial y'} = \frac{(1+y'(x)^2)^{\frac{1}{2}-1}}{2} \cdot \frac{\partial (y')^2}{\partial y'} = \frac{y'}{\sqrt{1+y'(x)^2}} $$ And now the last step would be $$ \frac{d}{dx}\left(\frac{\partial f}{\partial y'}\right) = \frac{y'' \sqrt{1+y'(x)^2} - \frac{y'}{\sqrt{1+y'(x)^2}} y' y'' }{1+y'(x)^2} = \frac{y'' + y''y'^2-y''y'^2}{\sqrt{1+y'(x)^2}^{3/2}} $$ Therefore as $\frac{\partial y'}{\partial y}=0$ the Euler equation is $$ \frac{-y''(x)}{(1+y'(x)^2)^{\frac{3}{2}}} = 0 $$ what happens when $y''(x)=0 \implies y'(x)=a \implies y(x)=ax+b$. Where $a=\frac{y_1-y_2}{x_1-x_2}$ and $b=\frac{-y_1 x_2+x_1 y_2}{x_1-x_2}$ the straight line that joins the points.