Solution to a quadratic form
Write this in a basis with respect to which $D$ is diagonal. Then I think you can see better what is going on. You can do this using a basis of orthogonal vectors. Also, if $D$ is positive definite, you might find the Cholesky factorization less computationally intensive.