TITLE: Solve an overdetermined system of linear equations
QUESTION [5 upvotes]: I have doubt to solve this system of equations
\begin{cases}
x+y=r_1\\
x+z=c_1\\
x+w=d_1\\
y+z=d_2\\
y+w=c_2\\
z+w=r_2
\end{cases}
Is it an overdetermined system because I see there are more equations than unknowns.
Can we just solve this system in a simple way?

REPLY [2 votes]: Start with the linear system
$$
\begin{align}
  \mathbf{A} x &= b \\
\left[
\begin{array}{cccc}
 1 & 1 & 0 & 0 \\
 1 & 0 & 1 & 0 \\
 1 & 0 & 0 & 1 \\
 0 & 1 & 1 & 0 \\
 0 & 1 & 0 & 1 \\
 0 & 0 & 1 & 1 \\
\end{array}
\right]
%
\left[
\begin{array}{c}
 x_{1} \\
 x_{2} \\
 x_{3} \\
 x_{4} 
\end{array}
\right]
%
&=
%
\left[
\begin{array}{c}
 b_{1} \\
 b_{2} \\
 b_{3} \\
 b_{4} \\
 b_{5} \\
 b_{6}
\end{array}
\right]
%
\end{align}
$$
We see that
$$
  \mathbf{A} \in \mathbb{R}^{6\times 4}_{4}, \quad
  b \in \mathbb{R}^{6}, \quad
  x \in \mathbb{R}^{4};
$$
that is $\mathbf{A}$ has $m=6$ rows, $n=4$ columns, and has rank $\rho=4$. The nullspace vectors reveal 
$$
\mathcal{N}\left(\mathbf{A}^{*}\right) = \text{span} \left\{
\left[
\begin{array}{r}
  1 \\
  0 \\
 -1 \\
 -1 \\
  0 \\
  1
\end{array}
\right]
,
\left[
\begin{array}{r}
  0 \\
  1 \\
 -1 \\
 -1 \\
  1 \\
  0
\end{array}
\right]
%
\right\}
$$
Let's look at this problem using the method of least squares. As long as the data vector $b$ is not in the nullspace, there will be a least squares solution. The normal equations offer easy resolution:
$$
\begin{align}
  \mathbf{A}^{*}\mathbf{A} x &= \mathbf{A}^{*} b \\[5pt]
%
\left[
\begin{array}{cccc}
 3 & 1 & 1 & 1 \\
 1 & 3 & 1 & 1 \\
 1 & 1 & 3 & 1 \\
 1 & 1 & 1 & 3 \\
\end{array}
\right]
%
\left[
\begin{array}{c}
 x_{1} \\
 x_{2} \\
 x_{3} \\
 x_{4} 
\end{array}
\right]
%
 &=
%
\left[
\begin{array}{c}
 b_1 + b_2 + b_3 \\
 b_1 + b_4 + b_5 \\
 b_2 + b_4 + b_6 \\
 b_3 + b_5 + b_6 
\end{array}
\right].
%
\end{align}
$$
The least squares solution is 
$$
\begin{align}
 x_{LS} &= \left( \mathbf{A}^{*}\mathbf{A} \right)^{-1} \mathbf{A}^{*} b \\[5pt]
%
 &=
%
\frac{1}{12}
\left[
\begin{array}{rrrrr}
  5 & -1 & -1 & -1 \\
 -1 &  5 & -1 & -1 \\
 -1 & -1 &  5 & -1 \\
 -1 & -1 & -1 &  5 \\
\end{array}
\right]
%
\left[
\begin{array}{c}
 b_1 + b_2 + b_3 \\
 b_1 + b_4 + b_5 \\
 b_2 + b_4 + b_6 \\
 b_3 + b_5 + b_6 
\end{array}
\right]\\[5pt]
% 
 &=
%
\frac{1}{6}
\left[
\begin{array}{rcrcrcrcrcrc}
 2 b_1 & + & 2 b_2 & + & 2 b_3 & - & b_4 & - & b_5 & - & b_6 \\ 
 2 b_1 & - & b_2 & - & b_3 & + & 2 b_4 & + & 2 b_5 & - & b_6 \\
  -b_1 & + & 2 b_2 & - & b_3 & + & 2 b_4 & - & b_5 & + & 2 b_6 \\
  -b_1 & - & b_2 & + & 2 b_3 & - & b_4 & + & 2 b_5 & + & 2 b_6 
\end{array}
\right]
%
\end{align}
$$
Because the problem has full column rank $m=\rho=4$, $\mathcal{N}\left( \mathbf{A}\right) = \left\{ \mathbf{0} \right\}$ the solution is unique.
Is this the direct solution where $\mathbf{A}x - b = 0$? The residual error vector shows the constraints required for a direct solution.
$$
  r(x) = \mathbf{A}x - b =
%
\frac{1}{6}
%
\left[
\begin{array}{rcrcrcrcrcrc}
 -2 b_{1} & + & b_{2} & + & b_{3} & + & b_{4} & + & b_{5} & - & 2 b_{6} \\
    b_{1} & - & 2 b_{2} & + & b_{3} & + & b_{4} & - & 2 b_{5} & + & b_{6} \\
    b_{1} & + & b_{2} & - & 2 b_{3} & - & 2 b_{4} & + & b_{5} & + & b_{6} \\
    b_{1} & + & b_{2} & - & 2 b_{3} & - & 2 b_{4} & + & b_{5} & + & b_{6} \\
    b_{1} & - & 2 b_{2} & + & b_{3} & + & b_{4} & - & 2 b_{5} & + & b_{6} \\
 -2 b_{1} & + & b_{2} & + & b_{3} & + & b_{4} & + & b_{5} & - & 2 b_{6}
\end{array}
\right]
$$