Null space of square matrix $A$ by using Gaussian Elimination - How? I have a matrix:

$$A = \begin{bmatrix}
23.941&amp;    30.000&amp;    20.000&amp;    14.000 \\
30.000&amp;    49.941&amp;    32.000&amp;    49.000\\
20.000&amp;    32.000&amp;    20.941&amp;    32.000\\
14.000&amp;    49.000&amp;    32.000&amp;   108.941
\end{bmatrix}$$

And I want to find the null space by using gaussian elimination.

First of all, I know that the null vector is: (and my goal is to find the eigenvectors from $A$ where I already know the eigenvalues! This vector is one eigenvector)

$$x = \begin{bmatrix}
0.40870 \\
   0.20893\\
  -0.88130\\
   0.11237
\end{bmatrix}$$

I first do gaussian elimination so my matrix looks like this:

$$A = \begin{bmatrix}
23.940999984741210938&amp; 30.000000000000000000&amp; 20.000000000000000000&amp; 14.000000000000000000\\ 
0.000000000000000000&amp; 12.348587036132812500&amp; 6.938390731811523438&amp; 31.456872940063476562\\ 
0.000000000000000000&amp; 0.000000000000000000&amp; 0.334734916687011719&amp; 2.629678726196289062\\ 
0.00000000000000000&amp;   0.000000000000000000&amp; 0.000000000000000000&amp; -0.038000106811523438 
\end{bmatrix}$$

Notice that I have using an algoritm for this!

Now what next? I have my matrix and I have reduce it to upper triangular. Can I find the null space now? What can I do with the number $A(4,4) = -0.038000106811523438$?

I update my question:

&gt;&gt; B % We start with this matrix
B =

  -2.62801   0.37593   0.12769
   0.37593  -4.71395  -1.05542
   0.12769  -1.05542  -0.23703

&gt;&gt; x = null(B) % We can find the null vector here
x =

   0.016349
  -0.217213
   0.975987

&gt;&gt; B*x % We can see that B*x will become zero, at least very close to zero
ans =

   4.1633e-17
  -2.2204e-16
   1.1380e-15

&gt;&gt; [u, s, v] = svd(B); % Or we can look at the last u column
&gt;&gt; u(:, 3)
ans =

   0.016349
  -0.217213
   0.975987

&gt;&gt;
You’ve got a bit of a problem here since the reduced matrix clearly has full rank, so its only null vector is $0$. Indeed, the original matrix $A$ is nonsingular: its determinant is equal to $-3.755$, so it’s not even close. Also, if you compute $Ax$, you’ll find that its elements, though small, aren’t particularly close to zero. Their first three places after the decimal point are zero, though, so at the limit of precision that you’ve got in the original data, it could be considered a null vector.  

When working with inexact data like this, even if you know theoretically that the matrix should be singular, the actual matrix that you work with might turn out not be so in practice. On top of that, Gaussian elimination isn’t a particularly stable algorithm, so it can introduce its own errors as well. A common way to deal with this is to approximate a null vector of the matrix by computing its SVD (singular value decomposition) and then taking the right singular vector that corresponds to the smallest singular value. It appears that this is what Octave did. Computing the SVD of $A$ in Mathematica yields $(0.408695,0.208933,-0.881299,0.112373)$ for this, which jibes with the vector $x$ in your question. The corresponding singular value is $0.000478394$, which, since the matrix is symmetric, has the same absolute value as its least-modulus eigenvalue. This is zero to three places, which is about as good as the input data that you have.  

In Matlab, you can compute the SVD of a matrix by using the function svd, not surprisingly. See the documentation for how to interpret its results. Since you’re looking for a right null vector, you’ll need to extract a singular vector from the “$V$” matrix—the right-hand one.



Will Jagy’s observation that your matrix $A$ appears to be an integer matrix plus a multiple of the identity leads me to suspect that the underlying problem that you’re trying to solve is finding eigenvectors of the integer matrix $$B=\begin{bmatrix}23&amp;30&amp;20&amp;14\\30&amp;49&amp;32&amp;49\\20&amp;32&amp;20&amp;32\\14&amp;49&amp;32&amp;103\end{bmatrix}$$ and indeed, to three decimal places one of its eigenvalues is $-0.941$. However, this is not a very well-conditioned matrix and the one you obtained by adding $0.941\,I$ to it is even worse. What this means is that it’s going to be very sensitive to truncation and other sources of error. Try this experiment: see what happens to the value of the determinant of $B-\lambda I$ as you add more and more significant digits to the approximation of this eigenvalue: carrying more precision in the approximation to the eigenvalue gets us closer and closer to singularity. Unfortunately, this also makes the matrix more and more ill-conditioned, which is bad news for Gaussian elimination. Indeed, when doing this same experiment with row-reduction instead of determinants, Mathematica eventually starts throwing warnings that the result of RowReduce may contain significant numerical errors.  

From the reduced matrix in your question it looks like you’re actually carrying more precision in your calculations than you have in the matrix $A$ in your question, but if the digits after the $23$ in the reduced matrix are the more precise value that you got for this eigenvalue, then it’s off by quite a bit. That’s also going to throw off your calculations, so you might want to double-check how you’re computing eigenvalues.
You’ve got a bit of a problem here since the reduced matrix clearly has full rank, so its only null vector is $0$. Indeed, the original matrix $A$ is nonsingular: its determinant is equal to $-3.755$, so it’s not even close. Also, if you compute $Ax$, you’ll find that its elements, though small, aren’t particularly close to zero. Their first three places after the decimal point are zero, though, so at the limit of precision that you’ve got in the original data, it could be considered a null vector.  

When working with inexact data like this, even if you know theoretically that the matrix should be singular, the actual matrix that you work with might turn out not be so in practice. On top of that, Gaussian elimination isn’t a particularly stable algorithm, so it can introduce its own errors as well. A common way to deal with this is to approximate a null vector of the matrix by computing its SVD (singular value decomposition) and then taking the right singular vector that corresponds to the smallest singular value. It appears that this is what Octave did. Computing the SVD of $A$ in Mathematica yields $(0.408695,0.208933,-0.881299,0.112373)$ for this, which jibes with the vector $x$ in your question. The corresponding singular value is $0.000478394$, which, since the matrix is symmetric, has the same absolute value as its least-modulus eigenvalue. This is zero to three places, which is about as good as the input data that you have.  

In Matlab, you can compute the SVD of a matrix by using the function svd, not surprisingly. See the documentation for how to interpret its results. Since you’re looking for a right null vector, you’ll need to extract a singular vector from the “$V$” matrix—the right-hand one.



Will Jagy’s observation that your matrix $A$ appears to be an integer matrix plus a multiple of the identity leads me to suspect that the underlying problem that you’re trying to solve is finding eigenvectors of the integer matrix $$B=\begin{bmatrix}23&amp;30&amp;20&amp;14\\30&amp;49&amp;32&amp;49\\20&amp;32&amp;20&amp;32\\14&amp;49&amp;32&amp;103\end{bmatrix}$$ and indeed, to three decimal places one of its eigenvalues is $-0.941$. However, this is not a very well-conditioned matrix and the one you obtained by adding $0.941\,I$ to it is even worse. What this means is that it’s going to be very sensitive to truncation and other sources of error. Try this experiment: see what happens to the value of the determinant of $B-\lambda I$ as you add more and more significant digits to the approximation of this eigenvalue: carrying more precision in the approximation to the eigenvalue gets us closer and closer to singularity. Unfortunately, this also makes the matrix more and more ill-conditioned, which is bad news for Gaussian elimination. Indeed, when doing this same experiment with row-reduction instead of determinants, Mathematica eventually starts throwing warnings that the result of RowReduce may contain significant numerical errors.  

From the reduced matrix in your question it looks like you’re actually carrying more precision in your calculations than you have in the matrix $A$ in your question, but if the digits after the $23$ in the reduced matrix are the more precise value that you got for this eigenvalue, then it’s off by quite a bit. That’s also going to throw off your calculations, so you might want to double-check how you’re computing eigenvalues.