<s>[INST] 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.
 [/INST] 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. 
$$
</s>