When does a sequence of rotated-and-circumscribed rectangles converge to a square?

Recently I came up with an algebra problem with a nice geometric representation. Basically, I would like to know what happens if we repeatedly circumscribe a rectangle by another rectangle which is rotated by $\alpha \in \left( 0, \frac {\pi} {4}\right)$ radians. Use this picture as reference:

In particular, do the resulting rectangles converge to a square?

It is rather easy to show that the rectangles do converge to a square if $\alpha$ is constant throughout the process. However, if we make it more general by defineing a sequence $\left(\alpha_n\right)_{n=1}^{\infty}$ of angles and use $\alpha_i$ in the $i$‘th operation, then the answer seems to depend on the chosen sequence. So, for which sequences $\left(\alpha_n\right)_{n=1}^{\infty}$ do the rectangles converge to a square?

Algebraically this problem can be defined like this:

Define two real sequences by $A_0=a, B_0=b, a \neq b, a,b \in R_{\gt0}$ and $A_{n+1}=B_n\sin\alpha_n + A_n\cos\alpha_n, B_{n+1}=A_n\sin\alpha_n + B_n\cos\alpha_n \forall n \in N_{\gt 0}$, where $\alpha_i \in \left( 0, \frac {\pi} {4}\right) \forall i \in N_{\ge 0}$. Is it true that $\lim_{n \to \infty}\frac{A_n}{B_n}=1$?

I tried out a few sequences in C++ to notice some patterns. Interestingly, rectangles seem to converge to a square if and only if $\lim_{n \to \infty} \left( \sum_{i=0}^n \alpha_i \right) = \infty$. In particular, for $\alpha_n = \frac{1}{n}$ the convergence is really slow, however, it still seems to be converging.

Also, I believe that showing $\lim_{n \to \infty}\left(A_n-B_n\right)=1$ would be an even stronger result for this problem. Does such a replacement have any influence on the result?

For the record, I am still a high school student, so I have no idea how hard this problem might actually be. Any help would be highly appreciated.

P.S. This is my first question on the site, so please don’t judge my wording and style too much. Feel free to ask questions if anything is unclear.

This is a particularly good first question!

Using a little linear algebra, we can actually write sufficiently explicit formulas for $$AnA_n$$ and $$BnB_n$$ to confirm your conjecture, namely that the divergence of $$∑∞i=1αi\sum_{i = 1}^{\infty} \alpha_i$$ is sufficient and necessary.

First, by writing the recurrence relations for $$AnA_n$$ and $$BnB_n$$ in matrix notation and applying a straightforward induction, we get that, for all nonnegative integers $$nn$$,
$$\require{cancel} \pmatrix{A_n \\ B_n} = \left(\prod_{i = 1}^n \underbrace{\pmatrix{\cos \alpha_i & \sin \alpha_i \\ \sin \alpha_i & \cos \alpha_i}}_{\Gamma_i}\right) \pmatrix{a \\ b} . \require{cancel} \pmatrix{A_n \\ B_n} = \left(\prod_{i = 1}^n \underbrace{\pmatrix{\cos \alpha_i & \sin \alpha_i \\ \sin \alpha_i & \cos \alpha_i}}_{\Gamma_i}\right) \pmatrix{a \\ b} .$$
We can make this more explicit by employing the standard trick of diagonalization: The eigenvalues of $$\Gamma_i\Gamma_i$$ are $$\lambda_i^{\pm} := \cos \alpha_i \pm \sin \alpha_i\lambda_i^{\pm} := \cos \alpha_i \pm \sin \alpha_i$$, so for $$\alpha_i\alpha_i$$ in the given range, we have that
$$0 < \lambda_i^- < \lambda_i^+ ,0 < \lambda_i^- < \lambda_i^+ ,$$
and in particular the eigenvalues are distinct, guaranteeing that we can write
$$\Gamma_i = P_i \pmatrix{\lambda_i^- & 0 \\ 0 & \lambda_i^+} P_i^{-1}\Gamma_i = P_i \pmatrix{\lambda_i^- & 0 \\ 0 & \lambda_i^+} P_i^{-1}$$ for some $$P_iP_i$$. In fact, since the rotations $$\Gamma_i\Gamma_i$$ all commute with one another (and are diagonalizable) they are simultaneously diagonalizable, that is, we can choose all of the $$P_iP_i$$ to be the same matrix $$PP$$. Computing eigenvectors corresponding to the eigenvalues shows that we may take $$P = \pmatrix{\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ -\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}}},P = \pmatrix{\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ -\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}}},$$ the rotation matrix for a clockwise rotation of $$\frac{\pi}{4}\frac{\pi}{4}$$ (see the remark below).

Our observation about being able to use the same $$PP$$ for all rotations pays off immediately, as the expression for the product $$\prod_{i = 1}^n \Gamma_i\prod_{i = 1}^n \Gamma_i$$ of rotations simplifies dramatically:
$$\prod_{i = 1}^n \Gamma_i = \prod_{i = 1}^n \left[P \pmatrix{\lambda_i^- & 0 \\ 0 & \lambda_i^+} P^{-1} \right] = P \pmatrix{\prod_{i = 1}^n \lambda_i^- & 0 \\ 0 & \prod_{i = 1}^n \lambda_i^+} P^{-1}. \prod_{i = 1}^n \Gamma_i = \prod_{i = 1}^n \left[P \pmatrix{\lambda_i^- & 0 \\ 0 & \lambda_i^+} P^{-1} \right] = P \pmatrix{\prod_{i = 1}^n \lambda_i^- & 0 \\ 0 & \prod_{i = 1}^n \lambda_i^+} P^{-1}.$$
This yields explicit formulas for $$A_n, B_nA_n, B_n$$ in terms of $$a, b, (\alpha_i)a, b, (\alpha_i)$$:
$$\pmatrix{A_n \\ B_n} = \left(\prod_{i = 1}^n \Gamma_i\right) \pmatrix{a \\ b} = \pmatrix{\frac{1}{2}(a + b) \prod_{i = 1}^n \lambda_i^+ + \frac{1}{2} (a - b) \prod_{i = 1}^n \lambda_i^- \\ \frac{1}{2}(a + b) \prod_{i = 1}^n \lambda_i^+ + \frac{1}{2}(b - a) \prod_{i = 1}^n \lambda_i^-} .\pmatrix{A_n \\ B_n} = \left(\prod_{i = 1}^n \Gamma_i\right) \pmatrix{a \\ b} = \pmatrix{\frac{1}{2}(a + b) \prod_{i = 1}^n \lambda_i^+ + \frac{1}{2} (a - b) \prod_{i = 1}^n \lambda_i^- \\ \frac{1}{2}(a + b) \prod_{i = 1}^n \lambda_i^+ + \frac{1}{2}(b - a) \prod_{i = 1}^n \lambda_i^-} .$$

Dividing and rewriting gives
$$\frac{A_n}{B_n} = \frac{\frac{1}{2}(a + b) \prod_{i = 1}^n \lambda_i^+ + \frac{1}{2} (a - b) \prod_{i = 1}^n \lambda_i^-}{\frac{1}{2}(a + b) \prod_{i = 1}^n \lambda_i^+ + \frac{1}{2}(b - a) \prod_{i = 1}^n \lambda_i^-} = \frac{1 + \mu_n}{1 - \mu_n},\frac{A_n}{B_n} = \frac{\frac{1}{2}(a + b) \prod_{i = 1}^n \lambda_i^+ + \frac{1}{2} (a - b) \prod_{i = 1}^n \lambda_i^-}{\frac{1}{2}(a + b) \prod_{i = 1}^n \lambda_i^+ + \frac{1}{2}(b - a) \prod_{i = 1}^n \lambda_i^-} = \frac{1 + \mu_n}{1 - \mu_n},$$
where
$$\mu_n := \frac{a - b}{a + b} \prod_{i = 1}^n \frac{\lambda_i^-}{\lambda_i^+} = \frac{a - b}{a + b} \prod_{i = 1}^n \frac{\cos \alpha_i - \sin \alpha_i}{\cos \alpha_i + \sin \alpha_i} = \frac{a - b}{a + b} \prod_{i = 1}^n \tan \left(\frac{\pi}{4} - \alpha_i\right) , \mu_n := \frac{a - b}{a + b} \prod_{i = 1}^n \frac{\lambda_i^-}{\lambda_i^+} = \frac{a - b}{a + b} \prod_{i = 1}^n \frac{\cos \alpha_i - \sin \alpha_i}{\cos \alpha_i + \sin \alpha_i} = \frac{a - b}{a + b} \prod_{i = 1}^n \tan \left(\frac{\pi}{4} - \alpha_i\right) ,$$
and $$0 < \mu_n < 10 < \mu_n < 1$$.

So, if $$\limsup \alpha_i > 0\limsup \alpha_i > 0$$, then $$\mu_n \to 0\mu_n \to 0$$ and hence $$\frac{A_n}{B_n} \to 1\frac{A_n}{B_n} \to 1$$. If, on the other hand, $$\limsup \alpha_i = 0\limsup \alpha_i = 0$$, we need not have $$\mu_n \to 0\mu_n \to 0$$. For small $$\alpha_i\alpha_i$$, $$\tan \left(\frac{\pi}{4} - \alpha_i\right) \sim 1 - 2 \alpha_i\tan \left(\frac{\pi}{4} - \alpha_i\right) \sim 1 - 2 \alpha_i$$, so for $$\frac{A_n}{B_n} \to 1\frac{A_n}{B_n} \to 1$$ I believe it's sufficient and necessary for $$\sum_{i = 1}^{\infty} \alpha_i\sum_{i = 1}^{\infty} \alpha_i$$ to diverge.

Similarly, we get
\begin{align*}\lim_{n \to \infty} (A_n - B_n) &= (a - b) \prod_{i = 1}^n (\cos \alpha_i - \sin \alpha_i) . \end{align*}\begin{align*}\lim_{n \to \infty} (A_n - B_n) &= (a - b) \prod_{i = 1}^n (\cos \alpha_i - \sin \alpha_i) . \end{align*}
Again, $$\limsup \alpha_i > 0\limsup \alpha_i > 0$$ is sufficient to guarantee vanishing. For the case $$\limsup \alpha_i = 0\limsup \alpha_i = 0$$ we can use $$\cos \alpha_i - \sin \alpha_i \sim 1 - \alpha_i\cos \alpha_i - \sin \alpha_i \sim 1 - \alpha_i$$ to conclude that $$A_n - B_n \to 0A_n - B_n \to 0$$ iff $$\sum_{i = 1}^{\infty} \alpha_i\sum_{i = 1}^{\infty} \alpha_i$$ diverges.

Remark The Jordan decomposition $$\Gamma_i = P \pmatrix{\lambda_i^- & 0 \\ 0 & \lambda_i^+} P^{-1}\Gamma_i = P \pmatrix{\lambda_i^- & 0 \\ 0 & \lambda_i^+} P^{-1}$$ is in this problem more than a convenient tool---it also gives some geometrical insight into why rotating and circumscribing makes rectangles more squarelike. The matrix $$P^{-1}P^{-1}$$ rotates a vector in the $$abab$$-plane (which we can view as a vector from the rectangle to one of its corners) by $$\frac{\pi}{4}\frac{\pi}{4}$$. Then $$\Gamma_i\Gamma_i$$ shears the rotated vector, lengthening its component in the direction that corresponds to the quantity $$a + ba + b$$ and shortening its component in the direction that corresponds to $$a - ba - b$$, which we may view as the absolute defect from squareness. Finally, the matrix $$PP$$ rotates back the one-eighth of a turn, which we may view as returning back to the original $$abab$$-coordinates.