I need help understanding what's happening mathematically when we rotate and scale a square and fit it within itself and repeat the process. For example: I can start with a square that has a dimension of $250 \times 250$ (purple square, shown in the reference image below). Then rotate it $45$ degrees and then scale it down so that it fits perfectly within the original $250 \times 250$ square, thus scaling the square down to the size of $176.78 \times 176.78$ (red square). Then when I do it again, I get the green square, $125 \times 125$.
I want to understand what's happening here mathematically and see if there's a mathematical equation I can use to be able to accurately calculate the size of a square after it's been rotated and scaled-down based on its initial value/state. That if I start with a square that's $250 \times 250$, how can I mathematically rotate and scale the square so that it would output $176.78$? Then I take that number, $176.78$, and do the same thing done on $250$, to arrive at $125$.
I figured the blue square would be useful in some way, still not sure, but it doesn't appear to accurately "lead" me into $125$, but it's a cheat to $125$ after getting $176.78$. But I need to get to $176.78$ first.
I thought I found a solution by doing: $250$ / $70.7%$ / $2$ but that returns $176.8033946$. Why $70.7%$? Idk, was literally just trying anything that would result in something consistent and that was the closest thing I could find, but it's inaccurate and as you repeat the process, it just becomes more and more inaccurate.
Any help would be appreciated, and hopefully, this makes sense.
If you draw the original square at $250 \times 250$ and draw a diagonal from one side to the other, you can use the Pythagorean theorem $\sqrt {a^2 + b^2}$ to find the length of the diagonal.
Notice that when you draw the diagonal, you get a right triangle with $45$ degree angles on each side. If you know trigonometry, $\sin 45^{\circ} = \cos 45^{\circ} = \dfrac {\sqrt 2}{2},$ hence a formula for rotating the square by $45$ degrees and fitting it into new sides would be $$\text {side length }_{\text {rotated square}} = \dfrac {x \sqrt {2}}{2}$$
Each time you take the new side and and rotate by $45$ degrees, the square will reduce by $70.71\%$ (as $\dfrac {\sqrt {2}}{2} \approx .7071$).
Using the information you supplied, let $x = 250$, then the first rotated square will be $125 \sqrt{2} \approx 176.78.$ Rotating again with these new sides gives us $125 \sqrt 2 \cdot \dfrac {\sqrt 2}{2} = \dfrac {250}{2} = 125$.