I came up with the following identity.

If z = x y = r**2 + d,

then

x * ( x + y - 2 * r) = ( r - x) **2 + d

Proof

x * (x + y - 2 * r) = x**2 + x y - 2 * x * r = x**2 + z - 2 * x * r

= x**2 - 2 * x * r + z

= x**2 - 2 * x * r + r**2 + d = ( r - x)**2 + d

Kermit