What is the length and angle of the longest rectangle of given width that can fit within another rectangle of given width and height? I have a particular engineering challenge that I'd like to solve, namely, given a rectangle of length X and width Y, what is the longest rectangle of width $\omega$ that I can fit inside? Additionally, I'd like to know the angle $\alpha$ of the inner rectangle with respect to the outer one. Here's a simple diagram:

I believe thus boils down to a system of 2 equations with 2 variables ($\lambda, \alpha$):
$$
X = \omega \cdot sin(\alpha) + \lambda \cdot cos(\alpha) \\
Y = \omega \cdot cos(\alpha) + \lambda \cdot sin(\alpha)
$$
But there's a 3rd equation that pops out too; the sum of the areas of the inner rectangle and the triangles around it must equal the area of the outer rectangle:
$$
X \cdot Y = \omega \cdot \lambda + \omega^2 \cdot cos(\alpha) \cdot sin(\alpha) + \lambda^2 \cdot cos(\alpha) \cdot sin(\alpha)
$$
The variables: $X, Y, \omega$ are given real numbers. I'd like to be able to represent $\lambda$ and $\alpha$ symbolically and independently of one another, if possible.
If I start by isolating $\lambda$ in the first equation, I get:
$$\begin{align}
\lambda \cdot cos(\alpha) &= X - \omega \cdot sin(\alpha) \\
\lambda &= \frac{X-\omega \cdot \sin(\alpha)}{cos(\alpha)}
\end{align}$$
That seems simple enough. Substituting this value in for $\lambda$ in the second equation, I get:
$$
Y = \omega \cdot cos(\alpha) + sin(\alpha) \cdot \left[ \frac{X-\omega \cdot \sin(\alpha)}{cos(\alpha)} \right]
$$
distributing $sin(\alpha)$ and find like denominators:
$$\begin{align}
Y &= \omega \cdot cos(\alpha) + \frac{X \cdot sin(\alpha)}{cos(\alpha)} - \frac{\omega \cdot sin^2(\alpha)}{cos(\alpha)} \\
Y &= \frac{\omega \cdot cos^2(\alpha)}{cos(\alpha)} + \frac{X \cdot sin(\alpha)}{cos(\alpha)} - \frac{\omega \cdot sin^2(\alpha)}{cos(\alpha)}
\end{align}$$
Re-arrange terms and use a double-angle identity:
$$\begin{align}
Y &= \frac{\omega \cdot cos^2(\alpha) + X \cdot sin(\alpha) - \omega \cdot sin^2(\alpha)}{cos(\alpha)} \\
Y &= \frac{\omega \cdot \left [ cos^2(\alpha) - sin^2(\alpha) \right ] + X \cdot sin(\alpha)}{cos(\alpha)} \\
Y &= \frac{\omega \cdot cos(2\alpha) + X \cdot sin(\alpha)}{cos(\alpha)}
\end{align}$$
I get stuck here, as I don't really know how to isolate $\alpha$. Any pointers?
EDIT: I added additional context, a diagram and an extra equation.
 A: Write $\cos\alpha=k$ so the equation becomes
$$Y=\frac{\omega(2k^2-1)+X\sqrt{1-k^2}}k$$
$$(kY-\omega(2k^2-1))^2=X^2(1-k^2)$$
This leaves a quartic equation in $k$ which can be solved by numerical means, and from there $\alpha$ may be derived.
A: Possible idea  (?)
Since, according to comments and answers, you will end with a quartic equation, you will need a numerical method. So, why not to use
$$X^2+Y^2=2 \lambda  \omega  \sin (2 \alpha )+\lambda ^2+\omega ^2$$
$$X^2-Y^2=(\lambda ^2-\omega ^2)\cos (2 \alpha )$$ Using $x=\lambda ^2$, we end with
$$x^4+ A x^3+B x^2+C x +D=0$$ where
$$A=-2 \left(X^2+Y^2\right)$$
$$B=2 \omega ^2 \left(X^2+Y^2\right)+\left(X^2+Y^2\right)^2-2 \omega ^4$$
$$C=2 \omega ^2 \left(\omega ^2 \left(X^2+Y^2\right)+X^4+Y^4-6 X^2 Y^2\right)$$
$$D=\omega ^4 \left(X^2+Y^2-\omega ^2\right)^2$$
A: A hallway of width a = 5 ft meets a hallway of width b = 4 ft at a right angle. Find the smallest ladder that could be carried around the corner. (Hint: Express the Length of the ladder as a function of the angle Ɵ in the given figure)
