CommencerCommencer gratuitement

Intro to The Matrix Inverse

We talked briefly about the identity matrix in the video. Another important concept to understand in matrix multiplication is that of the matrix inverse.

For any number \(a\) (aside from \(0\)), there's always a number \(\frac{1}{a}\) that can be used to "undo" multiplication by \(a\).

For matrices, this is not always true. However, when it is, we call the matrix that, when applied to \(A\), yields the identity matrix \(I\), that matrix's inverse.

The solve() function in R will find the inverse of a matrix if it exists and provide an error if it does not.

Cet exercice fait partie du cours

Linear Algebra for Data Science in R

Afficher le cours

Instructions

  • \(A\) is loaded for you. Show that the inverse of the identity matrix with \(n = 2\) is the identity matrix with \(n = 2\).

  • Find the inverse of the matrix \(A\) with the following R output:

> A
     [,1] [,2]
[1,]    1    2
[2,]   -1    2

and assign it to the variable Ainv.

  • Multiply Ainv by A in both directions. What is the resulting matrix?

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Take the inverse of the 2 by 2 identity matrix
solve(diag(___))

# Take the inverse of the matrix A
Ainv <- ___(A)

# Multiply A inverse by A
___%*%A

# Multiply A by its inverse
A%*%___
Modifier et exécuter le code