
Perimeter of rectangle,
$P = 2x + 2y$
Where:
$x = D \cos \theta$
$y = D \sin \theta$
$P = 2D \cos \theta + 2D \sin \theta$
$\dfrac{dP}{d\theta} = -2D \sin \theta + 2D \cos \theta = 0$
$-\sin \theta + \cos \theta = 0$
$\sin \theta = \cos \theta$
$\dfrac{\sin \theta}{\cos \theta} = 1$
$\tan \theta = 1$
$\theta = 45^\circ$
$x = D \cos 45^\circ = 0.707D$
$y = D \sin 45^\circ = 0.707D$
$x = y \, \text{ (square)}$ answer
See also the solution using algebraic function.