# Can someone explain the concept of B= null(A) in simple words?

32 views (last 30 days)
Lucifer__ on 6 Nov 2019
Commented: Lucifer__ on 7 Nov 2019
if A = [1,2,3,4,5]
B=null(A) gives something like this :
B =
-0.2697 -0.4045 -0.5394 -0.6742
0.9359 -0.0961 -0.1282 -0.1602
-0.0961 0.8558 -0.1923 -0.2403
-0.1282 -0.1923 0.7437 -0.3204
-0.1602 -0.2403 -0.3204 0.5995
can someone please explain in simple words what null does to the values of A? I would appreciate if no wiki links are shared.

John D'Errico on 6 Nov 2019
Edited: John D'Errico on 6 Nov 2019
Think of A as a vector pointing someplace in a 5 dimensional space. Got that? It points somewhere.
Now, in 5 dimensions, we could imagine 5 axis vectors, all pointing in orthogonal directions to each other. We could now align ONE of those axes with the vector we just saw described in A. That leaves 4 other axis vectors all orthogonal to the vector A.
Now, typically, in 5 dimensions, we could imagine 5 axes, each one defined by the vectors comprising columns of the matrix eye(5).
eye(5)
ans =
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
So each row (or coliumn, for that matter) can be viewed as a vector pointing along one axis of a 5 dimensional cartesian space. Together, they span a 5 dimensional space, so any vector in that space can be represented as some linear combinations of the columns of eye(5).
But if we then rotated our R^5 space, so that one of those vectors were pointing in the same direction as the vector A, then the other axis vectors must also change, so that all were orthogonal to A.
A = [1 2 3 4 5]
A =
1 2 3 4 5
B = null(A)
ans =
-0.26968 -0.40452 -0.53936 -0.6742
0.93591 -0.096129 -0.12817 -0.16021
-0.096129 0.85581 -0.19226 -0.24032
-0.12817 -0.19226 0.74366 -0.32043
-0.16021 -0.24032 -0.32043 0.59946
The columns of B are all orthogonal to the vector A. They can be viewed as together with A, an orthogonal set of vectors that still span the space. Clearly, you can see that A kills off any of the columns of B. (Ignoring the floating point trash that results.)
A*B
ans =
-2.2204e-16 2.2204e-16 -4.4409e-16 8.8818e-16
Essentially, whatever set of vectors you have in the rows of A, null finds a set of vectors that are orthogonal to the rows of A.
A realy good explanation of all this would also include an explanation of what orth does, as sort of the complement to null. But the best explanation would involve a course in linear algebra, and a good understanding of tools like SVD or possibly QR, to understand how those tools can be used to derive what null and orth produce.
I really wanted to add a wiki reference in this. It was hard not to do so. Sigh.

#### 1 Comment

Lucifer__ on 7 Nov 2019
Thank you for your answer. Yes, a course in Linear Algebra is what I have in mind. I am actually editing some code which has this function and I was wondering the use of this. Wiki got past my head but this made sense.

James Tursa on 6 Nov 2019
Edited: James Tursa on 6 Nov 2019
The columns of B form basis vectors for the "null space" of A. Any linear combination of the B columns, when multiplied by A, will give a 0 result (within floating point numerical tolerances). E.g.,
A * (B * rand(4,1)) --> 0 result using a random linear combination of B columns
>> A = [1,2,3,4,5]
A =
1 2 3 4 5
>> B=null(A)
B =
-0.2697 -0.4045 -0.5394 -0.6742
0.9359 -0.0961 -0.1282 -0.1602
-0.0961 0.8558 -0.1923 -0.2403
-0.1282 -0.1923 0.7437 -0.3204
-0.1602 -0.2403 -0.3204 0.5995
>> A * (B * rand(4,1))
ans =
5.5511e-17
>> A * (B * rand(4,1))
ans =
-2.2204e-16
>> A * (B * rand(4,1))
ans =
1.1102e-16
>> A*B
ans =
1.0e-15 *
0 -0.2220 0 0.4441

#### 1 Comment

Steven Lord on 6 Nov 2019
This can be useful because once you've found one solution to a system of equations, you can add any combination of multiples of vectors in the null space (returned by null) and get another solution.
A = magic(4);
xsol1 = [1; 2; 3; 4];
b = A*xsol1;
Obviously, by the way we constructed b, xsol1 is a solution to A*x = b.
check1 = A*xsol1 - b % Should contain only small values
But it's not the only one.
N = null(A, 'r'); % Use 'r' to get "nice" numbers in N
xsol2 = xsol1 + N;
check2 = A*xsol2 - b
xsol3 = xsol1 + 42*N;
check3 = A*xsol3 - b
xsol4 = xsol1 - pi*N;
check4 = A*xsol4 - b
This is because A*(xsol1 + N) is just A*xsol1 + A*N. A*N by definition is the zero vector, and A*xsol1 is b.
shouldBeZeros = A*N
Let's prove that the four solutions I computed are not the same.
[xsol1, xsol2, xsol3, xsol4]
The four solutions contain very different values, but they are all solutions.