The sides of a right triangle are on the coordinate axes and its hypotenuse passes through the $(1,8)$ .how to minimize the length of the hypotenuse? Q: The sides of a right triangle are on the coordinate axes and its hypotenuse passes through the point $(1,8)$ . Find the vertices of this triangle such that the length of the hypotenuse is minimum
I've been having trouble setting up this problem. 

At first, I thought I'd make $S$ into 
$S= d_1 + d_2$
$d_1= \sqrt{(1-0)^2 + (8-y)^2}$
$\to d_1=\sqrt{y^2-16y+65}$
$d_2 = \sqrt{(1-x)^2+(8-0)^2}$
$\to d_2 = \sqrt{x^2-2x+65}$
$ \to S = \sqrt{y^2-16y+65} + \sqrt{x^2-2x+65}$
After this, I know that we find the derivative of S and minimize with that, but how do I relate $x$ & $y$ so that I can write 
$y$ in terms of $x$ , since I think I first need to write S in terms of one variable.
Thanks for the help
 A: the line passing through $(1,8)$ has equation
$y-8=m(x-1)\;\;y=mx-m+8$
which intersect $x-$axis at $\left(\dfrac{m-8}{m};\;0\right)$ and $y-$axis at $(0;\;8-m)$
Hypotenuse $h(m)=\sqrt{\left(\dfrac{m-8}{m}\right)^2+(8-m)^2}$
as square root is an increasing function, $h(m)$ will be minimum when 
$r(m)=\left(\dfrac{m-8}{m}\right)^2+(8-m)^2=m^2+\dfrac{64}{m^2}-16 m-\dfrac{16}{m}+65$
will be minimum
$r'(m)=-\dfrac{128}{m^3}+\dfrac{16}{m^2}+2 m-16=\dfrac{2 \left(m^4-8 m^3+8 m-64\right)}{m^3}$
$m^4-8 m^3+8 m-64=0\to (m-8) (m^3-8) =0$
$m=8$ gives hypotenuse $h(8)=0$ which makes no sense
$m^3=8\to m=2$ gives $h(2)=3 \sqrt{5}$ which is the minimum we were looking for
indeed second derivative is $r''(m)=\dfrac{2 \left(m^4-16 m+192\right)}{m^4}$ and $r''(2)=22>0$
it is positive at $m=2$  so it is a minimum
hope this helps
A: Hint...let the angle between the line and the $x$ axis be $\theta$ so that the length of the line is $$8\csc\theta+\sec\theta$$ which differentiates nicely...
A: Giving method of Lagrange Multiplier solution  very briefly.
Let the equation of straight line be
$$ \frac{x}{a}+\frac{y}{b}=1 \tag1 $$
Satisfies $(1,8)$ so plugging in this point,we get constraint $f(a,b)$
$$8a+b -a\,b =0 = f(a,b), say \tag2 $$
$$ \frac{f_a}{f_b}=\frac{8-b}{1-a} \tag3$$
Next object function length 
$$ g(a,b) =\sqrt{a^2+b^2}\tag4 $$
$$ \frac{g_a}{g_b}=\frac{a}{b} \tag5$$
(on simplifying)
Next Lagrangian $$f(a,b)- \lambda g(a,b) \tag6$$
needs the above two quotients.
$$ \frac{f_a}{f_b}= \frac{g_a}{g_b}= \lambda \tag7 $$
Solving (2), (7) we get intercepts:
$$  (a,b)=(5,10) \tag8$$
Please feel free to ask any clarification.
