
By ratio and proportion
$\dfrac{y}{x} = \dfrac{30}{40}$
$y = \frac{3}{4}x$
By Pythagorean theorem
$d = \sqrt{(40 - x)^2 + y^2}$
$d = \sqrt{(40 - x)^2 + (\frac{3}{4}x)^2}$
$d = \sqrt{(40 - x)^2 + \frac{9}{16}x^2}$
For minimum length of d, differentiate then equate to zero
$\dfrac{dd}{dx} = \dfrac{2(40 - x)(-1) + \frac{9}{8}x}{2\sqrt{(40 - x)^2 + \frac{9}{16}x^2}} = 0$
$-2(40 - x) + \frac{9}{8}x = 0$
$\frac{25}{8}x = 80$
$x = 25.6 \, \text{ cm}$
Distance of D from side AB for minimum length of d
$y = \frac{3}{4}(25.6)$
$y = 19.2 \, \text{ cm}$ answer
The same problem was solved by Geometry alone. See the solution here: Distance between projection points