With two $N$-vectors $x$ and $y$, I calculate $z := x - y$. I also have an $N \times N$ covariance matrix $Q$ and calculate the following: \begin{align*} x^\top Qx &= a\\ y^\top Qy &= b\\ z^\top Qz &= c \end{align*}
Is there any way to calculate a new matrix $K$ such that $x^\top Kx = c$?
I have an optimization problem where I want to solve for $x$, but implement a constraint on $z$ which I haven't been able to setup. So I am hoping to be able to have the constraint on $x$ too but using a different matrix in it.
As $x$ isn't known prior to the optimization solution I think $K$ would need to be calculated using only $y$ and $Q$ which are both known.
I'm not sure if what I'm trying to achieve is possible but any help would be appreciated.
Observe that $c = x'Qx - 2x'Qy + b$. So let $x,y\in\mathbb R^N$, and $Q\in\mathbb R^{N\times N}$. Put $$ W := \begin{bmatrix} Q & -2Qy \\ 0 & b \end{bmatrix}\qquad\text{and}\qquad \tilde x:= \begin{bmatrix} x \\ 1 \end{bmatrix}.$$ Then $$\begin{align*} \tilde x'W\tilde x &= \begin{bmatrix} x' & 1 \end{bmatrix}\begin{bmatrix} Q & -2Qy \\ 0 & b \end{bmatrix}\begin{bmatrix} x \\ 1 \end{bmatrix} \\ &=\begin{bmatrix} x'Q + 0 &-2x'Qy+b\end{bmatrix}\begin{bmatrix} x \\ 1 \end{bmatrix} \\ &=x'Qx -2x'Qy + b \\ &= c.\end{align*}$$ So there exists a matrix such that $\tilde x W\tilde x = c$. However, note that you need to modify your $x$ by concatenating a $1$ to the vector (that is, $\tilde x$ is a linear-affine transformation).
Edit: So what you can do is the following. $W$ is the matrix you are looking for. Then optimize the objective function $$\mathcal L(\tilde x, \lambda) = \tilde x' W\tilde x + \lambda (\iota'\tilde x - 1)$$ over $\mathbb R^{N+1}$, where $\iota$ is a vector of zeros except for the last, i. e. the $(N+1)$th, component where there is a one.