
The inside box is skewed which makes it a more difficult geometry problem but the centers of the two are at the same point.
$(cd)^2 = (a-x)^2 + (b-y)^2$
and so
$d^2 = \frac{(a-x)^2 + (b-y)^2}{c^2}$………….(1)
$y^2 = d^2 – x^2$………………………….(2)
$d^2+ (cd)^2 = (a-2x)^2 + b^2$
$d^2(c^2+1) = (a-2x)^2 + b^2$
$d^2 = \frac{(a-2x)^2 + b^2}{(c^2+1)}$…………(3)
Substituting…..
$d^2 = \frac{(a-x)^2 + (b-\sqrt{(d^2-x^2)})^2}{c^2}$ gets rid of the y term
$\frac{(a-2x)^2 + b^2}{c^2+1} = \frac{(a-x)^2 + (b-\sqrt{(\frac{(a-2x)^2 + b^2}{(c^2+1)}–x^2}))^2}{c^2}$ gets rid of the d terms.
For $a = 9, b = 6$ and $c = 5$,
$117-18x-12\sqrt{\frac{4x^2-36x+117}{26}-x^2}-24\frac{4x^2-36x+117}{26} = 0$
then $x = .875, y = 1.625, d = 1.8456$ and $cd = 9.2280$
Edit: I corrected some errors and have verified the result.
To solve $117-18x-12\sqrt{\frac{4x^2-36x+117}{26}-x^2}-24\frac{4x^2-36x+117}{26} = 0$
Using Newton's method to solve for $x$...............
$x_1 = x_0 - \frac{f(x_0)}{f'(x_0)}$
Then $x_{n+1} = x_n - \frac{f(n)}{f'(n)}$
$f(x) = 117-18x-12\sqrt{\frac{4x^2-36x+117}{26}-x^2}-24\frac{4x^2-36x+117}{26}$
and $f'(x) = -18 - \frac{(192x-864)}{26}-\frac{\frac{48x-216}{26}-12x}{\sqrt{\frac{4x^2-36x+117}{26}-x^2}}$
$x_0 = 1$
$x_1 = 1 - \frac{2.4617}{20.1016} = .8775$
$x_2 = .8775 - \frac{.0484}{19.3607} = .8750$
$x = .875$
Let me try to explain further but before I do, I did find an error in the derivative. The good news about this is it converges on a solution much faster. There are 3 equations with 3 unknowns $x, y$ and $d$. We are given $a, b$ and $c$ so we use the equation $\frac{(a-2x)^2 + b^2}{c^2+1} = \frac{(a-x)^2 + (b-\sqrt{(\frac{(a-2x)^2 + b^2}{(c^2+1)}–x^2}))^2}{c^2}$ to solve for $x$, then $y$ and $d$.
$a = 9, b = 6$, and $c = 5$ so......
$\frac{(9-2x)^2 + 6^2}{5^2+1} = \frac{(9-x)^2 + (6-\sqrt{(\frac{(9-2x)^2 + 6^2}{(5^2+1)}–x^2}))^2}{5^2}$
$\frac{4x^2 - 36x + 117}{26} = \frac{(x^2 - 18x + 81) + (6-\sqrt{(\frac{(4x^2 - 36x + 117)}{(26)}–x^2}))^2}{25}$
$25\frac{(4x^2 - 36x + 117)}{26} = (x^2 - 18x + 81) + (6-\sqrt{(\frac{(4x^2 - 36x + 117)}{(26)}–x^2}))^2$
$25\frac{(4x^2 - 36x + 117)}{26} = x^2 - 18x + 81 + 36-12\sqrt{(\frac{(4x^2 - 36x + 117)}{(26)}–x^2}) + \frac{4x^2-36x+117}{26} - x^2$
$25\frac{(4x^2 - 36x + 117)}{26} = - 18x + 117 - 12\sqrt{(\frac{(4x^2 - 36x + 117)}{(26)}–x^2}) + \frac{4x^2-36x+117}{26}$
$24\frac{(4x^2 - 36x + 117)}{26} = - 18x + 117 - 12\sqrt{(\frac{(4x^2 - 36x + 117)}{(26)}–x^2})$
$0 = - 18x + 117 - 12\sqrt{(\frac{(4x^2 - 36x + 117)}{(26)}–x^2})-24\frac{(4x^2 - 36x + 117)}{26}$
Hence $117-18x-12\sqrt{\frac{4x^2-36x+117}{26}-x^2}-24\frac{4x^2-36x+117}{26} = 0$
This just goes through my calculations to get to the Newton's method formula for this particular problem with actual values of $a, b$ and $c$.
Really, not knowing values for $a, b$ and $c$ beforehand, you should work with the equation
$\frac{(a-2x)^2 + b^2}{c^2+1} = \frac{(a-x)^2 + (b-\sqrt{(\frac{(a-2x)^2 + b^2}{(c^2+1)}–x^2}))^2}{c^2}$
$c^2((a-2x)^2 + b^2) = (c^2+1)((a-x)^2 + (b-\sqrt{(\frac{(a-2x)^2 + b^2}{(c^2+1)}–x^2}))^2$
Which will reduce to...............
$(a^2 + b^2) -2ax-2b\sqrt{\frac{(a-2x)^2 + b^2}{c^2 + 1}-x^2}-(c^2 - 1)\frac{(a-2x)^2 + b^2}{c^2 + 1} = 0$
Then for Newton's method.....
$$f(x) = (a^2 + b^2) -2ax-2b\sqrt{\frac{(a-2x)^2 + b^2}{c^2 + 1}-x^2}-(c^2 - 1)\frac{(a-2x)^2 + b^2}{c^2 + 1}$$
$$f'(x) = -2a + \frac{4(c^2-1)(a-2x)}{c^2+1}-\frac{\frac{-4b(a-2x)}{c^2+1}-2bx}{\sqrt{\frac{(a-2x)^2 + b^2}{c^2 + 1}-x^2}}$$
Where $a$ and $b \ (a > b)$ are the length and width of the outer rectangle and c is the aspect ratio $(\frac{\text{length}}{\text{width}})$ of the inner rectangle.
box2will touchbox1on all four sides, with the degenerate case of both rectangles coinciding when aspect ratios allow. – hardmath Jun 19 '18 at 22:52