Using a matrix inverse to solve a system of equations