Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Inversed and Transposed Matrices | Linear Algebra
Mathematics for Data Analysis and Modeling
course content

Course Content

Mathematics for Data Analysis and Modeling

Mathematics for Data Analysis and Modeling

1. Basic Mathematical Concepts and Definitions
2. Linear Algebra
3. Mathematical Analysis

bookInversed and Transposed Matrices

Matrix Transposition

In linear algebra, the transpose of a matrix is an operation that flips the matrix over its diagonal, resulting in a new matrix where the rows become columns, and the columns become rows. The transpose of a matrix A is denoted as A^T.
We can provide transponation of matrix in Python in two different ways:

  1. Using .T attribute of np.array class;
  2. Using np.transpose() method.
1234567891011121314151617181920
import numpy as np # Define a matrix matrix = np.array([[1, 2, 3], [4, 5, 6]]) # Calculate the transpose using the `.T` attribute transpose_matrix = matrix.T print('Original matrix:') print(matrix) print('\nTransposed matrix using .T attribute:') print(transpose_matrix) # Calculate the transpose using the `transpose()` function transpose_matrix = np.transpose(matrix) print('\nTransposed matrix using np.transpose():') print(transpose_matrix)
copy

Matrix Inversion

In linear algebra, the inverse of a square matrix A is a matrix denoted as A^-1, which, when multiplied by the original matrix A, results in the identity matrix I. The inverse of a matrix exists only if the determinant of the matrix is non-zero.

Note

An identity matrix, denoted as I, is a square matrix with ones on the main diagonal (from the top left to the bottom right) and zeros elsewhere. In other words, all elements in the main diagonal are equal to 1, while all other elements are equal to 0.

It's important to admit that A * A^-1 = A^-1 * A = I - the multiplication operation by the inversed matrix is commutative.

In Python, you can use the .inv() method of the np.linalg module to calculate the inverse of a matrix. Here's an example:

1234567891011121314151617181920
import numpy as np # Define a matrix matrix = np.array([[1, 2], [3, 4]]) # Calculate the inverse using the `inv()` function inverse_matrix = np.linalg.inv(matrix) print('Original matrix:') print(matrix) print('\nInverse matrix:') print(inverse_matrix) # Multiply the original matrix by its inverse identity_matrix = np.dot(matrix, inverse_matrix) print('\nIdentity matrix:') print(np.round(identity_matrix, 3))
copy
How can we find inversed matrix using `NumPy`?

How can we find inversed matrix using NumPy?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 6
some-alt