Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Linear Algebra for Data Science in R

Cursus bekijken

Oefeninstructies

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

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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%*%___
Code bewerken en uitvoeren