Note that the expected output was an identity matrix. Although you have 1 s along the major diagonal, the float operations returned not zeros but numbers very close to zero off-diagonal. Numpy has a ...