Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Matrix Operations | Linear Algebra Foundations
Mathematics for Data Science

bookMatrix Operations

Matrices are powerful tools for representing and solving mathematical problems. Before jumping into linear systems, like Ax=bA\vec{x} = \vec{b}, it's essential to understand how matrices behave and what operations we can perform on them.

Matrix Addition

You can add two matrices only if they have the same shape (same number of rows and columns).

Let:

A=[a11a12a21a22],B=[b11b12b21b22]A = \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix}, \quad B = \begin{bmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \end{bmatrix}

Then:

A+B=[a11+b11a12+b12a21+b21a22+b22]A + B = \begin{bmatrix} a_{11} + b_{11} & a_{12} + b_{12} \\ a_{21} + b_{21} & a_{22} + b_{22} \end{bmatrix}

Scalar Multiplication

You can also multiply a matrix by a scalar (single number):

kA=[ka11ka12ka21ka22]k \cdot A = \begin{bmatrix} k a_{11} & k a_{12} \\ k a_{21} & k a_{22} \end{bmatrix}

Matrix Multiplication and Size Compatibility

Matrix multiplication is a row-by-column operation, not element-wise.

Rule: if matrix AA is of shape (m×n)(m \times n) and matrix BB is of shape (n×p)(n \times p), then:

  • The multiplication ABAB is valid;
  • The result will be a matrix of shape (m×p)(m \times p).

Example:

Let:

A=[1234],  B=[56]A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}, \ \ B = \begin{bmatrix} 5 \\ 6 \end{bmatrix}

AA is (2×2)(2 \times 2) and BB is (2×1)(2 \times 1), then ABAB is valid and results in a (2×1)(2 \times 1) matrix:

AB=[15+2635+46]=[1739]A \cdot B = \begin{bmatrix} 1 \cdot 5 + 2 \cdot 6 \\ 3 \cdot 5 + 4 \cdot 6 \end{bmatrix} = \begin{bmatrix} 17 \\ 39 \end{bmatrix}

Transpose of a Matrix

The transpose of a matrix flips rows and columns. It is denoted as ATA^T.

Let:

A=[1234]A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}

Then:

AT=[1324]A^T = \begin{bmatrix} 1 & 3 \\ 2 & 4 \end{bmatrix}

Properties:

  • (AT)T=A(A^T)^T = A;
  • (A+B)T=AT+BT(A + B)^T = A^T + B^T;
  • (AB)T=BTAT(AB)^T = B^T A^T.

Determinant of a Matrix

2×2 Matrix

For:

A=[abcd]A = \begin{bmatrix} a & b \\ c & d \end{bmatrix}

The determinant is:

det(A)=adbc\det(A) = ad - bc

3×3 Matrix

For:

A=[abcdefghi]A = \begin{bmatrix} a & b & c \\ d & e & f \\ g & h & i \end{bmatrix}

The determinant is:

det(A)=a(eifh)b(difg)+c(dheg)\det(A) = a(ei - fh) - b(di - fg) + c(dh - eg)

This method is called cofactor expansion.

  • Larger matrices (4×4 and up) can be expanded recursively.
  • The determinant is useful because it indicates whether a matrix has an inverse (non-zero determinant).

Inverse of a Matrix

The inverse of a square matrix AA is denoted as A1A^{-1}. It satisfies AA1=IA \cdot A^{-1} = I, where II is the identity matrix.

Only square matrices with non-zero determinant have an inverse.

Example:

If matrix A is:

A=[abcd]A = \begin{bmatrix} a & b \\ c & d \end{bmatrix}

Then its inverse matrix A1A^{-1} is:

A1=1det(A)[dbca]A^{-1} = \frac{1}{\det(A)} \begin{bmatrix} d & -b \\ -c & a \end{bmatrix}

Where det(A)0\det(A) \neq 0.

1. What is the shape of the product of a (2×3)(2 \times 3) matrix and a (3×4)(3 \times 4) matrix?

2. What condition must be met for ABAB to be valid?

3. What is the transpose of [1234]\begin{bmatrix}1 & 2 \\3 & 4\end{bmatrix} matrix?

4. If AA is a (3×3)(3 \times 3) matrix and BB is (3×2)(3 \times 2), what is the shape of ABAB?

5. Only square matrices can be multiplied.

6. The transpose of a (2×3)(2 \times 3) matrix is (3×2)(3 \times 2).

question mark

What is the shape of the product of a (2×3)(2 \times 3) matrix and a (3×4)(3 \times 4) matrix?

Select the correct answer

question mark

What condition must be met for ABAB to be valid?

Select the correct answer

question mark

What is the transpose of [1234]\begin{bmatrix}1 & 2 \\3 & 4\end{bmatrix} matrix?

Select the correct answer

question mark

If AA is a (3×3)(3 \times 3) matrix and BB is (3×2)(3 \times 2), what is the shape of ABAB?

Select the correct answer

question mark

Only square matrices can be multiplied.

Select the correct answer

question mark

The transpose of a (2×3)(2 \times 3) matrix is (3×2)(3 \times 2).

Select the correct answer

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 4. Luku 3

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

Awesome!

Completion rate improved to 1.89

bookMatrix Operations

Pyyhkäise näyttääksesi valikon

Matrices are powerful tools for representing and solving mathematical problems. Before jumping into linear systems, like Ax=bA\vec{x} = \vec{b}, it's essential to understand how matrices behave and what operations we can perform on them.

Matrix Addition

You can add two matrices only if they have the same shape (same number of rows and columns).

Let:

A=[a11a12a21a22],B=[b11b12b21b22]A = \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix}, \quad B = \begin{bmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \end{bmatrix}

Then:

A+B=[a11+b11a12+b12a21+b21a22+b22]A + B = \begin{bmatrix} a_{11} + b_{11} & a_{12} + b_{12} \\ a_{21} + b_{21} & a_{22} + b_{22} \end{bmatrix}

Scalar Multiplication

You can also multiply a matrix by a scalar (single number):

kA=[ka11ka12ka21ka22]k \cdot A = \begin{bmatrix} k a_{11} & k a_{12} \\ k a_{21} & k a_{22} \end{bmatrix}

Matrix Multiplication and Size Compatibility

Matrix multiplication is a row-by-column operation, not element-wise.

Rule: if matrix AA is of shape (m×n)(m \times n) and matrix BB is of shape (n×p)(n \times p), then:

  • The multiplication ABAB is valid;
  • The result will be a matrix of shape (m×p)(m \times p).

Example:

Let:

A=[1234],  B=[56]A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}, \ \ B = \begin{bmatrix} 5 \\ 6 \end{bmatrix}

AA is (2×2)(2 \times 2) and BB is (2×1)(2 \times 1), then ABAB is valid and results in a (2×1)(2 \times 1) matrix:

AB=[15+2635+46]=[1739]A \cdot B = \begin{bmatrix} 1 \cdot 5 + 2 \cdot 6 \\ 3 \cdot 5 + 4 \cdot 6 \end{bmatrix} = \begin{bmatrix} 17 \\ 39 \end{bmatrix}

Transpose of a Matrix

The transpose of a matrix flips rows and columns. It is denoted as ATA^T.

Let:

A=[1234]A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}

Then:

AT=[1324]A^T = \begin{bmatrix} 1 & 3 \\ 2 & 4 \end{bmatrix}

Properties:

  • (AT)T=A(A^T)^T = A;
  • (A+B)T=AT+BT(A + B)^T = A^T + B^T;
  • (AB)T=BTAT(AB)^T = B^T A^T.

Determinant of a Matrix

2×2 Matrix

For:

A=[abcd]A = \begin{bmatrix} a & b \\ c & d \end{bmatrix}

The determinant is:

det(A)=adbc\det(A) = ad - bc

3×3 Matrix

For:

A=[abcdefghi]A = \begin{bmatrix} a & b & c \\ d & e & f \\ g & h & i \end{bmatrix}

The determinant is:

det(A)=a(eifh)b(difg)+c(dheg)\det(A) = a(ei - fh) - b(di - fg) + c(dh - eg)

This method is called cofactor expansion.

  • Larger matrices (4×4 and up) can be expanded recursively.
  • The determinant is useful because it indicates whether a matrix has an inverse (non-zero determinant).

Inverse of a Matrix

The inverse of a square matrix AA is denoted as A1A^{-1}. It satisfies AA1=IA \cdot A^{-1} = I, where II is the identity matrix.

Only square matrices with non-zero determinant have an inverse.

Example:

If matrix A is:

A=[abcd]A = \begin{bmatrix} a & b \\ c & d \end{bmatrix}

Then its inverse matrix A1A^{-1} is:

A1=1det(A)[dbca]A^{-1} = \frac{1}{\det(A)} \begin{bmatrix} d & -b \\ -c & a \end{bmatrix}

Where det(A)0\det(A) \neq 0.

1. What is the shape of the product of a (2×3)(2 \times 3) matrix and a (3×4)(3 \times 4) matrix?

2. What condition must be met for ABAB to be valid?

3. What is the transpose of [1234]\begin{bmatrix}1 & 2 \\3 & 4\end{bmatrix} matrix?

4. If AA is a (3×3)(3 \times 3) matrix and BB is (3×2)(3 \times 2), what is the shape of ABAB?

5. Only square matrices can be multiplied.

6. The transpose of a (2×3)(2 \times 3) matrix is (3×2)(3 \times 2).

question mark

What is the shape of the product of a (2×3)(2 \times 3) matrix and a (3×4)(3 \times 4) matrix?

Select the correct answer

question mark

What condition must be met for ABAB to be valid?

Select the correct answer

question mark

What is the transpose of [1234]\begin{bmatrix}1 & 2 \\3 & 4\end{bmatrix} matrix?

Select the correct answer

question mark

If AA is a (3×3)(3 \times 3) matrix and BB is (3×2)(3 \times 2), what is the shape of ABAB?

Select the correct answer

question mark

Only square matrices can be multiplied.

Select the correct answer

question mark

The transpose of a (2×3)(2 \times 3) matrix is (3×2)(3 \times 2).

Select the correct answer

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 4. Luku 3
some-alt