Can someone explain the concept of B= null(A) in simple words?
Show older comments
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.
Accepted Answer
More Answers (1)
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.
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!