Replacing pinv with inv in MATLAB

638 Views Asked by At

Let $\mathbf{y} = \mathbf{Ax}$ represent a system of equations where $A\in\mathbb{R}^{m\times m}, x\in\mathbb{R}^{m\times 1}$. However rank of $\mathbf{A}$ is $m-1$. I add another equation $\mathbf{b'x} = y_1$. Then I can get $\mathbf{x}$ as $\mathbf{x}_1 = \left[\mathbf{A};\mathbf{b}\right]^{\dagger}\left[\mathbf{y};y_1\right]$, where, $\left[\mathbf{A};\mathbf{b}\right]$is of rank $m$ and the $\dagger$ indicates pseudo inverse as the matrix is of size $m+1\times m$. Now let us remove the first row of $\left[\mathbf{A};\mathbf{b}\right]$ and write \begin{equation} \mathbf{A}_1 = \left[\mathbf{A}(2:end,:);\mathbf{b}\right]\\ \mathbf{z} = \left[\mathbf{y}(2:end);y_1\right] \end{equation} If I calculate $\mathbf{x}_2= \mathbf{A}_1^{-1}\mathbf{z}$, then which of $\mathbf{x}_1$ and $\mathbf{x}_2$ will be a more accurate value of $\mathbf{x}$?

1

There are 1 best solutions below

4
On BEST ANSWER

More accurate in what sense?

Your first method, adding an arbitrary new equation and using the pseudoinverse, gives you a vector whose image under $[{\bf A};{\bf b}]$ is as close as possible (in Euclidean distance) to $[{\bf y}; y_1]$; out of those vectors with that same image, it chooses the one with minimum length. In general it will not satisfy any of the system of equations.

Your second method, ignoring the first equation entirely, gives you a vector that satisfies all the equations except the first one, but since that first equation was ignored completely, the first entry of ${\bf A} {\bf x}$ could be anything. The Euclidean distance from $[{\bf A}; {\bf b}] {\bf x}$ to $[{\bf y}; y_1]$ will be at least as great as, and probably greater than, what was obtained in the first method.

However, it looks like you don't really care about that new equation you added; you might be more concerned with the distance from ${\bf A} {\bf x}$ to ${\bf y}$. We don't know which method will make this one smaller.

But I don't know why you put that new equation in at all. Why not use the pseudoinverse of $\bf A$ in the first place?