Carpetfizz
Carpetfizz

Reputation: 9169

Null space calculation for same matrix with different data type inconsistent

I'm running the following code to find the eigenvector corresponding to eigenvalue of 1 (to find the rotation axis of an arbitrary 3x3 rotation matrix).

I was debugging something with the identity rotation, but I'm getting two different answers.

R1 =

    1.0000   -0.0000    0.0000
    0.0000    1.0000    0.0000
   -0.0000         0    1.0000


R2 =

     1     0     0
     0     1     0
     0     0     1

Running the null space computation on each matrix.

null(R1 - 1 * eye(3))

>>   3x0 empty double matrix

null(R2 - 1 * eye(3))

>>
 1     0     0
 0     1     0
 0     0     1

Obviously the correct answer is the 3x0 empty double matrix, but why is R2 producing a 3x3 identity matrix when R1 == R2 ?

Upvotes: 0

Views: 314

Answers (1)

Iban Cereijo
Iban Cereijo

Reputation: 1675

It makes sense that the nullspace of a zero matrix (rank 0) is an identity matrix, as any vector x in R^3 will produce A*x = 0.

>> null(zeros(3, 3))
ans =

   1   0   0
   0   1   0
   0   0   1

This would be the case of R2 - eye(3) if R2 is exactly eye(3)

It also makes sense that the nullspace of a full rank matrix is an empty matrix, as no vectors different than 0 will produce A*x = 0:

>> null(eye(3))
ans = [](3x0)

which could be the case of R1 - eye(3) if R1 is not exactly eye(3) so the result is rank 3. For example:

>> R1 = eye(3) + 1e-12*diag(ones(3,1))
R1 =

   1.0000        0        0
        0   1.0000        0
        0        0   1.0000

>> null(R1 - 1 * eye(3))
ans = [](3x0)
>> rank(R1 - 1 * eye(3))
ans = 3

Upvotes: 2

Related Questions