<s>[INST] A fence of $y$ ft is $x$ ft from a wall, find shortest ladder using trigonometry 
A fence $y$ ft high is $x$ ft from a wall. Find the length of the
  shortest ladder that will rest with one end on the ground and the
  other end on the wall.

This is a classic problem that is expected to be solved with trigonometry but I can't seem to get the right answer.
First, let the angle between the ground and the ladder be $\theta$, I express the total length of the ladder $L$ as the sum of the length between the ground and the fence $l_1$ and the length between the fence and the wall $l_2$:
$$
l_1 = \frac{y}{\sin\theta} \\
l_2 = \frac{x}{\cos\theta} \\
L = l_1 + l_2 = \frac{y}{\sin\theta} + \frac{x}{\cos\theta} = y\csc\theta + x\sec\theta \\
$$
Then, since this is an optimization problem, I differentiate the length:
$$
L' = -y\csc\theta\cot\theta + x\sec\theta\tan\theta = \frac{-y\cos\theta}{\sin^2\theta} + \frac{x\sin\theta}{\cos^2\theta} \\
$$
With this equation, I find the critical point where the derivative is zero:
$$
\frac{y\cos\theta}{\sin^2\theta} = \frac{x\sin\theta}{\cos^2\theta} \\
\frac{y}{x} = \frac{\sin^3\theta}{\cos^3\theta} = \tan^3\theta \\
$$
Now I make the assumption that $tan\theta = (y/x)^{1/3}$ which I then proceed to replace in the equation for the length of the ladder:
$$
L = \frac{y\cos\theta}{\sin\theta\cos\theta} + \frac{x\sin\theta}{\cos\theta\sin\theta} = \frac{y}{\cos\theta\tan\theta} + \frac{x\tan\theta}{sin\theta} \\
L = \frac{y}{\cos\theta(y/x)^{1/3}} + \frac{x(y/x)^{1/3}}{\sin\theta} = \frac{y^{2/3}x^{1/3}}{\cos\theta} + \frac{x^{2/3}y^{1/3}}{\sin\theta}
$$
Finally I make another assumption that $sin\theta = y^{1/3}$ and $cos\theta = x^{1/3}$ because $tan\theta = (\sin\theta/\cos\theta) = (y/x)^{1/3}$:
$$
L = \frac{y^{2/3}x^{1/3}}{x^{1/3}} + \frac{x^{2/3}y^{1/3}}{y^{1/3}} = y^{2/3} + x^{2/3}
$$
But the actual answer is:
$$
L = (y^{2/3} + x^{2/3})^{3/2}
$$
So where did I miss the $3/2$ exponent?
 [/INST] Your last assumption is the problem:
$$
\tan\theta = \frac{\sin\theta}{\cos\theta} = (\frac{y}{x})^{1/3} \\
\frac{\sin^2\theta}{\cos^2\theta} = (\frac{y}{x})^{2/3} \\
x^{2/3}\sin^2\theta = y^{2/3}\cos^2\theta \\
\sin^2\theta + \cos^2\theta = \frac{y^{2/3}\cos^2\theta}{x^{2/3}} + \cos^2\theta \\
\cos^2\theta(\frac{y^{2/3}}{x^{2/3}} + 1) = 1 \\
\cos^2\theta = \frac{x^{2/3}}{y^{2/3} + x^{2/3}} \\
\cos\theta = \frac{x^{1/3}}{(y^{2/3} + x^{2/3})^{1/2}} \\
$$
If you do the same for $\sin\theta$, you get:
$$
\sin\theta = \frac{y^{1/3}}{(x^{2/3} + y^{2/3})^{1/2}} \\
$$
If you replace $\cos\theta$ and $\sin\theta$ with those expressions, you then get the right answer.
</s>