Matrix Operations

This lesson discusses various matrix operations.

Inverse

Suppose we have to solve the equation AX=bAX=b for bb.

If vector bb changes, one has to call np.linalg.solve() over and over. Instead, if A1A^{-1} were calculated once, matrix multiplication with bb could be done over and over, more efficiently, to obtain different solutions.

The inverse of a matrix may be computed with the inv function of the linalg package.

Let’s use the inverse of the matrix to obtain the solution to the problem in the first lesson.

AX=bAX=b

A1AX=A1bA^{-1}AX=A^{-1}b

X=A1bX=A^{-1}b

If the inverse of matrix A is called Ainv, the solution for the equation may be obtained through matrix multiplication of Ainv with the right-hand side. Let’s look at an implementation of this below.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy