Two halls 6 and 9 meters perpendicularly intersect. Optimization Two halls 6 and 9 meters perpendicularly intersect. Find the length of the longest straight bar to be passed horizontally from one aisle to another by a corner without deformation.

and this is my try:

How to find the equation to maximize in this problem.Please.
 A: We use your diagram. We calculate the length of the diagonal when the angle at the bottom is $\theta$. 
The part from the bottom to the obstructive corner is $\frac{9}{\sin \theta}$, and the rest is $\frac{6}{\cos\theta}$. We want to minimize $f(\theta)$, where 
$$f(\theta)=\frac{9}{\sin\theta}+\frac{6}{\cos\theta}.$$
To find the minimum, use the usual tools. We have
$$f'(\theta)=-\frac{9\cos\theta}{\sin^2\theta}+\frac{6\sin\theta}{\cos^2\theta}.$$
Set this equal to $0$. You will find that $\tan^3\theta$ has to be a certain quantity. 
Remark: A rectangular coordinates approach along the lines you are pursuing will also work, albeit a little less smoothly. I cannot make detailed comments, the work is difficult to read. 
A: This superficially appears to be a maximization problem but is really a minimization problem.  You've drawn some diagonal lines through the corner that you seem to have labeled $(-6,9)$.  You have to figure out which value of the coordinate you've called $x$ makes that diagonal line as short as possible.
You've got
$$
\begin{align}
g(x) = (x+6)^2 + \left( 9 + \frac{54}{x} \right)^2 & = (x+6)^2 + 81\left(\frac{x+6}{x}\right)^2 \\[10pt]
& = (x+6)^2\left( 1 + \frac{81}{x^2} \right).
\end{align}
$$
You need the value of $x$ that minimizes that.
Notice that $g(x)\to\infty$ as $x\downarrow0$ and $g(x)\to\infty$ as $x\to\infty$, and the function is continuous on $(0,\infty)$, so it must have a global minimum somewhere in between.  If there's only one place in that interval where $g'=0$, then that must be it.
Alright, in response to comments:
\begin{align}
g'(x) & = (x+6)^2 \frac{d}{dx}\left( 1 + \frac{81}{x^2} \right) + \left( 1 + \frac{81}{x^2} \right) \frac{d}{dx}(x+6)^2 \\[10pt]
& = (x+6)^2 \cdot\frac{-162}{x^3} + \left( 1 + \frac{81}{x^2} \right)2(x+6).
\end{align}
This is $0$ when $x=-6$, and at other points we can divide by $x+6$ both sides of the equation that sets the expression above equal to $0$.  We get
$$
(x+6) \cdot\frac{-162}{x^3} + \left( 1 + \frac{81}{x^2} \right)2 = 0.
$$
Multiplying both sides by $x^3$ we get
$$
(x+6)(-162) + (x^3 + 81x)2 = 0 
$$
$$
2x^3 - 972 = 0 , 
$$
$$
x^3 - 486 = 0
$$
$$
x = \sqrt[3]{486} =  3\sqrt[3]{18} \approx 7.86. 
$$
