ComeçarComece de graça

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.

Este exercício faz parte do curso

Linear Algebra for Data Science in R

Ver curso

Instruções do exercício

  • \(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?

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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%*%___
Editar e executar o código