-1

I have a matrix A that has some rows that are equal to each other. To my understanding, that means that its determinant should be zero. However, when using np.linalg.det(A), the resulting value is not zero. How can that be possible?

Minimal reproducible example below.

import numpy as np

A = np.array([[1.000014814814815, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482],
            [0.00001481481481481482, 1.000014814814815     , 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482],
            [0.00001481481481481482, 0.00001481481481481482, 0.00011481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00011481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00011481481481481482],
            [0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 1.000014814814815     , 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482],
            [0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 1.000014814814815     , 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482],
            [0.00001481481481481482, 0.00001481481481481482, 0.00011481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00011481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00011481481481481482],
            [0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 1.000014814814815     , 0.00001481481481481482, 0.00001481481481481482],
            [0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00001481481481481482, 1.000014814814815     , 0.00001481481481481482],
            [0.00001481481481481482, 0.00001481481481481482, 0.00011481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00011481481481481482, 0.00001481481481481482, 0.00001481481481481482, 0.00011481481481481482]])


print(np.linalg.det(A)) # output: 2.1089783600655513e-44
print(A[0][2] == A[0][-1]) # output: True
jared
  • 4,165
  • 1
  • 8
  • 31
nona
  • 84
  • 6
  • 5
    2.1089783600655513e-44 is 0.000000000000000000000000000000000000000000021[...], so it's safe to assume it _is_ zero, with an IEEE rounding error. Remember that you're using a computer with limited precision, always expected rounding errors. – Mike 'Pomax' Kamermans Aug 31 '23 at 14:02
  • 4
    It’s safe to eat that amount of plutonium. – aerobiomat Aug 31 '23 at 14:20

0 Answers0