# Linear Algebra: Solving the minimization with vector p-norm.

The course this question is from is called Wavefield imaging, It gives the vector p-norm of an N-by-1 vector $$x=[x_1,x_2,...,x_N]^T$$ is defined as $$||x||_p=\left(\sum_{n=1}^N |x_n|^p \right)^{1/p}$$ Suppose we are given a 3-by-1 data vector $$d=[d_1,d_2,d_3]^T$$ with $$d_1\geqslant d_2 \geqslant d_3$$. Let the system matrix be given by $$G=[1,1,1]^T$$ and let $$x$$ be real-valued scalar. Verify that

a)$$x_{opt}=\frac{d_1+d_2+d_3}{3}$$ solves the minimization problem $$x = \underset{x \in R}{\mathrm{argmin}} ||d-Gx||_2$$. The solution is equal to the arithmetic mean of the data.

In my attempted solution I tried to replace $$x$$ in $$||d-Gx||_2$$ with $$x_{opt}$$ as follows... $$Gx=[1,1,1]^T \cdot \frac{d_1+d_2+d_3}{3}= \begin{bmatrix} \frac{d_1+d_2+d_3}{3} \\ \frac{d_1+d_2+d_3}{3} \\ \frac{d_1+d_2+d_3}{3} \end{bmatrix}$$ Then I tried to put the resulting vector into $$||d-Gx||_2$$ $$||x||_2=\sqrt{\left|d_1-\frac{d_1+d_2+d_3}{3}\right|^2+\left|d_2-\frac{d_1+d_2+d_3}{3}\right|^2+\left|d_3-\frac{d_1+d_2+d_3}{3}\right|^2}$$ my final solution was like this $$||x||_2=\frac{d_1^2+d_2^2+d_3^2-4d_1d_2-4d_1d_3-4d_2d_3}{3}$$ I couldn't arrive at the correct solution, I checked some textbooks and the internet trying to figure out what I am doing wrong but I couldn't figure out how to arrive at the correct solution so any help would be much appreciated.

$$\|Gx-d\|^2=(x-d_1)^2+(x-d_2)^2+(x-d_3)^2$$
This is a quadratic in the variable $$x$$ whose minimal value is attained at $$x=\frac{d_1+d_2+d_3}{3}$$, which can easily be verified by differentiation.