Please help me with a single variable derivative applied question. I'm Will. I have a problem with a question.
A man 6 ft tall wants to construct a greenhouse of length L and width 18 ft against the outer wall of his house by building a sloping glass roof of slant height y from the ground to the wall, as shown in the figure below. He considers space in the greenhouse to be usable if he can stand upright without bumping his head. If the cost of building the roof is proportional to y, find the slope of the roof that minimizes the cost per square foot of usable space. Hint: Notice that this amounts to minimizing y/x.
      /|
     / |
  y /  |
   /   |
  /----|
 / |   |6
--------
18    x

Hmmm please don't mind my bad drawing. This is a cross section of the greenhouse. 
I have got to the position:
Let h be the height of the cross section.
h/ 18= (h- 6)/ x, using similar triangles.
So, xh= 18(h- 6).
Differentiating both sides with respect to x while h= (y^2- 18^2)^(1/2) and h'= yy'/(y^2- 18^2)^(1/2).I get: 
xh'+ h= 18h',
xyy'+ y^2- 18^2= 18yy'.   (1)
At the same time, because I should minimize (y/x), I differentiate it and get (xy'- y)/x^2, and it should be 0.
So y'= y/x.
I plug y'=y/x into equation (1) and I get 
x= 9y^2/(y^2- 9). (2)
Finally I'm totally stuck here. I get the solution which is only a '1' from the textbook without any explanations.
When I plug 1 as the slope into the figure, I find that x should be 12.
So, y should be 18*2^(1/2). But this is in contradiction to equation (2).
I'll be so appreciated for your help!
 A: here's one way to do it.  I hope it helps you:
Take the variable 'd' as the height of the triangular cross section above the mans head, or the height minus the man's height.  The rectangular area that the man could use separates two right triangles that are proportional such that the lower triangle 'a' contains the same angles as the upper one 'b' but are different sizes.  So 'd' can be expressed as the proportion of height to base of triangle 'a' times the base of triangle 'b' like this:
$d = x (\frac{6}{18-x})$
or
$d = \frac{6x}{18-x}$
//where $[18-x]$ is the base of triangle 'a' and 'x' is the base of 'b'
Now that 'd' is in terms of 'x' you can plug this into the Pythagorean theorem for the whole triangular cross-section to get a formula for the length of the sloped wall 'y' like so:
$\sqrt{18^2 + (6 + (\frac{6x}{18-x}))^2} = y$
//where 6 + (6x/[18-x]) is the man's height plus the distance 'd'
Divide that whole equation by 6x to find the ratio of the length 'y' to that which defines the usable rectangular area.
$\sqrt {18^2 + (6 + (\frac{6x}{18-x})}$  /ALL DIVIDED BY 6X   = 'R' ratio 
Finally upon differentiating this (it's very long so I used a calculator) the minimum value for the ratio is $x = 12$.  With 'x' as 12 you can clearly see the slope on triangle 'a' by computing
$18-12 = 6$ (base of triangle 'a')
man's height = 6 (height of triangle 'a')
so the slope of the beam 'y' is $6/6$ or '1'
A: With the hint, we wish to minimize $$\frac{y}{x},$$ given the following constraint $$y^{2} = 18^{2} + (\frac{108}{18-x})^{2}.$$
We use implicit differentiation, namely $$(\frac{y}{x})' = \frac{y'x-y}{x^{2}}$$ and $$(y^{2} = 18^{2} + (\frac{108}{18-x})^{2})'$$ gives $yy' = \frac{108^{2}}{(18-x)^{3}}.$
Now, the denominator of $\frac{y'x-y}{x^{2}}$ is positive (there must be some usable space), so the term vanishes if and only if the numerator vanishes. In other words, we require $y'= \frac{y}{x}.$ With this finding, we make a substitution such that $\frac{108^{2}}{(18-x)^{3}} = y (\frac{y}{x}) = \frac{y^{2}}{x}.$
We substitute the constraint in place of $y^{2}$ on the right hand side such that $\frac{108^{2}}{(18-x)^{3}} = \frac{18^{2} + (\frac{108}{18-x})^{2}}{x}.$ Then, we rewrite the equation as follows $\frac{x}{18-x} = 1 + (\frac{18-x}{6})^{2},$ where some algebraic steps have been omitted.
At this point, we substitute $u = 18-x,$ where $u$ denotes the horizontal length in the unusable part of the greenhouse. Namely, $\frac{18-u}{u} = 1 + (\frac{u}{6})^{2},$ which leads to the following cubic equation $u^{3} + 72u - 648 = 0.$ The only real solution is $u=6,$ which is in accord with John's previously posted solution. Therefore, the slope is equal to $1.$
