We have that $A$ is a symmetric matrix $n\times n$, $b$ is a $n\times 1$ vector, $C$ is a scalar, and $d$ is a $n\times 1$ vector.
The expression
$\left(Ad\right)'A^{-1}\left(Ad\right)-2b'A^{-1}Ad+C$
can be rewritten as
$\left(Ad-b\right)'A^{-1}\left(Ad-b\right)+C-b'A^{-1}b$
I really don't get where $b'A^{-1}b$ comes from. Any help?
Edited: Corrected B with b.
Your first term of the rewritten expression is:
$$\left(Ad-b\right)'A^{-1}\left(Ad-b\right)= (Ad)'A^{-1}(Ad) - 2b'A^{-1}Ad + b'A^{-1}b$$
and since $b'A^{-1}b$ is not in your original expression, you need to remove it.