Skip to content

The matrix multiplied by its own inverse is not equal to the identity matrix #12397

@youngseaz

Description

@youngseaz

Reproducing code example

# coding:utf-8
import numpy as np


def rand_matrix(m, n):
    temp = np.random.randint(m, n, [3, 3])
    return np.mat(temp)


def inversion(m, n):
    temp = rand_matrix(m, n)
    print("random matrix is:\n ", temp)
    try:
        output = temp.I
        print("random matrix's inversion is:\n", output)
        print(np.dot(temp, output))
        return output
    except np.linalg.linalg.LinAlgError as err:
        print("the matrix is singular matrix which inversion doesn't exist")


inversion(1, 20)

result:

example
I run the code several times. The result of running the code was similar to the screenshot. The code produces a random 3*3 matrix named temp, then calculates the inverse of the random matrix. Finally, I called numpy.dot() for examination. But the result exceeding my expectations, the result wasn't identity matrix

Numpy/Python version information:

Python --version 3.6.3
numpy --version 1.13.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions