Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 1

Matrix Operations: Multiplication and 2x2 Determinants

Recommended resources

Welcome to your first lesson. We'll begin our review of linear algebra by focusing on the fundamental hands-on skills your interviewers will expect you to have. This session is designed to refresh your ability to perform basic matrix operations by hand, specifically multiplication and the calculation of a 2x2 determinant.

Given your background, you've likely performed these operations many times before, so our goal is to reactivate that muscle memory. In a high-pressure, short interview, being able to quickly and accurately compute a simple matrix product or determinant on paper shows that your foundational knowledge is solid. These operations are the building blocks for nearly everything else we'll discuss in this module.

Let's get started.

What is a Matrix? A Quick Refresher

Before we jump into operations, let's briefly reset our terminology. A matrix is simply a rectangular grid of numbers arranged in rows and columns. This structure is fundamental to AI and data science, as it's the standard way to represent datasets, images, and the parameters of machine learning models.

We'll be focusing on 2x2 matrices today, but the concepts scale up.

Matrix in Data Science interviews | Towards Data Science

This section from the "Towards Data Science" article provides a quick, no-frills refresher on matrix notation.

Please read the section on matrix notation. Pay attention to how a matrix's dimensions (e.g., 2x3) are described and how individual elements are referenced using row and column indices (e.g., a_{ij}).


Matrix Multiplication

Matrix multiplication is one of the most common operations in linear algebra. It's not as simple as element-by-element multiplication; instead, it involves a "row-by-column" dot product procedure.

The Rule for Multiplication

The most important rule to remember—and a great point to make verbally if asked—is the condition for multiplication. To multiply two matrices, say A by B, the number of columns in A must equal the number of rows in B.

If A is an matrix and B is an matrix, their product AB will be an matrix. Notice the "inner" dimensions () must match.

Matrix in Data Science interviews | Towards Data Science

The same article explains this rule clearly.

In the section on "Matrix multiplication," focus on the subsection Matrix-matrix multiplication. This part explains the critical rule of matching inner dimensions.

The "Row-by-Column" Method

The best way to refresh the mechanics is to see them in action. Each element in the resulting matrix is calculated by taking the dot product of a row from the first matrix and a column from the second.

For a clearer demonstration than text can provide, the following short video walks through a 2x2 example step-by-step.

Matrix Multiplication || Example with Two 2x2 Matrices

The video "Matrix Multiplication || Example with Two 2x2 Matrices" by The Math Sorcerer provides a concise and clear walkthrough of the entire process.

Watch the video from the beginning to the calculation setup. The instructor explains how the position of an element in the new matrix tells you which row and column to use from the original matrices. Then, you can watch the final arithmetic to see the result.

To see the general formula written out and to review another worked example, you can refer to this resource from Statology.

Matrix Multiplication: (2x2) by (2x2)

This resource lays out the general formula and provides a clean example.

First, look at the general formula to see the algebraic structure. Then, walk through Example 1 to see it applied to numbers.

Practice: Multiplication

Now, take out your pen and paper. Let's compute a product by hand.

Calculate AB, where:

...

Solution:

Let's call the resulting matrix C.

  1. Top-left element (): Row 1 of A Column 1 of B
  2. Top-right element (): Row 1 of A Column 2 of B
  3. Bottom-left element (): Row 2 of A Column 1 of B
  4. Bottom-right element (): Row 2 of A Column 2 of B

So, the final matrix is:


The 2x2 Determinant

The determinant is a scalar value that can be computed from the elements of a square matrix. It has deep geometric meaning related to how a matrix transforms space (which we'll touch on later), but for now, we'll focus on the calculation. For a 2x2 matrix, the formula is very simple.

For a general 2x2 matrix A:

The determinant, denoted as or , is calculated as:

The general formula for the determinant of a 2x2 matrix is the product of the main diagonal elements minus the product of the off-diagonal elements.

The following video provides a quick tutorial with examples.

Determinant of 3x3 Matrices, 2x2 Matrix, Precalculus Video Tutorial

This video from The Organic Chemistry Tutor quickly demonstrates the calculation for a 2x2 matrix.

Watch the first part of the video, from the beginning up to the start of the 3x3 section. This covers the formula and two quick examples, which is all you need for this lesson.

Practice: Determinant

Time for another pen-and-paper exercise. This one is taken directly from a typical online problem set.

Calculate the determinant for the given 2x2 matrix M, following the formula you've just reviewed.

...

Solution:

Using the formula :

  1. Identify :
    , , ,
  2. Calculate :
  3. Calculate :
  4. Subtract from :

The determinant of matrix M is -13. Being comfortable with fractions is a good way to show you're not flustered by simple arithmetic.


Conclusion

In this lesson, we've refreshed two key procedural skills in linear algebra. You should now be able to confidently perform these calculations if asked during your interview.

Key Takeaways:

  • Matrix Multiplication: The product of two matrices A and B is only defined if the number of columns in A equals the number of rows in B. The calculation is performed using a "row-by-column" dot product method.
  • 2x2 Determinant: For a matrix , the determinant is the scalar value .

These operations are the absolute bedrock of computational linear algebra. In our next lesson, we will move to a more conceptual topic: matrix rank. We'll discuss how rank relates to the linear independence of a matrix's rows and columns, and what it tells us about the data the matrix represents.