# Minimizing the Mahalanobis distance

Definitions

Consider the following optimization problem $$\begin{equation*}\arg \min_{x\in\mathbb{R}^n} \lVert y-x\rVert_{P}^2\end{equation*}$$ where $$y,P$$ are given parameters and $$\begin{equation*} \lVert y-x\rVert_{P}^2 \triangleq (y-x)'P(y-x) \end{equation*}$$ assume that $$P$$ is a regular covariance matrix, that is $$P$$ is symmetric and strictly positive definite ($$P=P', P>0$$).

Question

Under the previous assumption $$P=P', P>0$$, is it true that $$\begin{equation*}\arg \min_{x\in\mathbb{R}^n} \lVert y-x\rVert_{P}^2= \arg \min_{x\in\mathbb{R}^n} \lVert y-x\rVert^2 \end{equation*}$$?

Observation

In the simple case $$2\times 2$$, with the additional hypothesis that $$P$$ is diagonal, the equality seems to be true. Indeed, by denoting $$\begin{equation*} y=\left[\begin{array}{c} y_1 \\ y_2 \end{array}\right] \qquad x=\left[\begin{array}{c} x_1 \\ x_2 \end{array}\right] \qquad P=\left[\begin{array}{cc} P_{11} & 0\\ 0 & P_{22} \end{array}\right] \end{equation*}$$ follows $$\begin{equation*} \lVert y-x\rVert_P^2= P_{11} (y_1-x_1)^2 + P_{22} (y_2-x_2)^2 \end{equation*}$$ now, due to the sum sign the objective is to jointly minimize $$P_{11} (y_1-x_1)^2$$ and $$P_{22} (y_2-x_2)^2$$. These are two decoupled problems, so they can be treated separately, that is we are searching for $$\begin{equation*} \arg\min_{x_i \in \mathbb{R}} P_{ii} (y_i - x_i)^2 \qquad i=1,2 \end{equation*}$$ now, since $$P_{ii}$$ is just a positive scaling factor, holds $$\begin{equation*} \arg\min_{x_i \in \mathbb{R}} P_{ii} (y_i - x_i)^2= \arg\min_{x_i \in \mathbb{R}} (y_i - x_i)^2 \qquad i=1,2 \end{equation*}$$ and so rolling back to the original problem $$\begin{equation*}\arg \min_{x\in\mathbb{R}^n} \lVert y-x\rVert_{P}^2= \arg \min_{x\in\mathbb{R}^n} \lVert y-x\rVert^2 \end{equation*}$$

Remark

I've proved that the equality holds in the diagonal $$2\times2$$ case. The extension to the diagonal $$n\times n$$ case is identical. My difficulty is that I'm not sure how to treat the non-diagonal case.

$$\nabla_x \left( \|y - x\|^2_P \right) = 2 P (y-x) = 0$$, so we have $$x = y$$,
$$y = \arg\min_{x \in \mathbb{R}^n} \,\|y - x\|^2_P$$
$$\nabla_x \left( \|y-x\|^2 \right) = 2(y-x) = 0$$, so we have $$x = y$$,
$$y = \arg \min_{x \in \mathbb{R}^n} \, \|y-x\|^2$$