MMULT function

The MMULT function in Excel is used to multiply two matrices. It returns the matrix product of two arrays, which is a fundamental operation in linear algebra.

Syntax

=MMULT(array1, array2)

Parameters

  • array1: The first matrix (or array) to multiply. This can be a range of cells that represent the first matrix.
  • array2: The second matrix (or array) to multiply. This can be a range of cells that represent the second matrix.

Return Value

The function returns the matrix product of array1 and array2. If the dimensions of the two arrays are not compatible for matrix multiplication, Excel will return the #VALUE! error.

Matrix Multiplication Rule

Matrix multiplication is only possible if the number of columns in the first matrix (array1) matches the number of rows in the second matrix (array2).

For example:

  • If array1 is a 2×3 matrix (2 rows, 3 columns), array2 must be a 3×2 matrix (3 rows, 2 columns) for the multiplication to be valid.
  • The result will be a new matrix with dimensions 2×2 (the number of rows from array1 and the number of columns from array2).

How It Works

  • The element in row i, column j of the resulting matrix is the sum of the product of the corresponding elements from row i of array1 and column j of array2.

For example: If matrix A is:

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

And matrix B is:

B=[efgh]B = \begin{bmatrix} e & f \\ g & h \end{bmatrix}

Then the result of A × B will be:

A×B=[a×e+b×ga×f+b×hc×e+d×gc×f+d×h]A \times B = \begin{bmatrix} a \times e + b \times g & a \times f + b \times h \\ c \times e + d \times g & c \times f + d \times h \end{bmatrix}

Example Usage

Example 1: 2×3 and 3×2 Matrix Multiplication

Let’s say we have two matrices:

  • Matrix 1 (A1:C2):
123
456
  • Matrix 2 (D1:E3):
78
910
1112

To multiply these two matrices, you would use the MMULT function like this:

=MMULT(A1:C2, D1:E3)

The result will be a 2×2 matrix:

[1×7+2×9+3×111×8+2×10+3×124×7+5×9+6×114×8+5×10+6×12]\begin{bmatrix} 1 \times 7 + 2 \times 9 + 3 \times 11 & 1 \times 8 + 2 \times 10 + 3 \times 12 \\ 4 \times 7 + 5 \times 9 + 6 \times 11 & 4 \times 8 + 5 \times 10 + 6 \times 12 \end{bmatrix}

Which simplifies to:

[5864139154]\begin{bmatrix} 58 & 64 \\ 139 & 154 \end{bmatrix}

Example 2: Multiplying a 3×1 Matrix with a 1×3 Matrix (Vector Multiplication)

If you multiply a 3×1 matrix (a column vector) with a 1×3 matrix (a row vector), you get a 3×3 matrix.

  • Matrix 1 (A1:A3): | 1 | |—| | 2 | | 3 |
  • Matrix 2 (B1:D1): | 4 | 5 | 6 |

You can use the MMULT function to multiply these:

=MMULT(A1:A3, B1:D1)

The result will be:

[1×41×51×62×42×52×63×43×53×6]\begin{bmatrix} 1 \times 4 & 1 \times 5 & 1 \times 6 \\ 2 \times 4 & 2 \times 5 & 2 \times 6 \\ 3 \times 4 & 3 \times 5 & 3 \times 6 \end{bmatrix}

Which simplifies to:

[45681012121518]\begin{bmatrix} 4 & 5 & 6 \\ 8 & 10 & 12 \\ 12 & 15 & 18 \end{bmatrix}

Important Notes

  • The MMULT function in Excel requires that the dimensions of the matrices are compatible for multiplication (i.e., the number of columns in the first matrix equals the number of rows in the second matrix).
  • The function will return a #VALUE! error if the matrices have incompatible dimensions.
  • Array Formula: In some versions of Excel (especially older versions), you may need to enter the MMULT function as an array formula. To do this, after typing the formula, press Ctrl+Shift+Enter instead of just Enter.

Common Uses

  • Financial Analysis: For portfolio analysis, matrix multiplication can be used to calculate the total return on a portfolio with multiple assets.
  • Linear Algebra: Matrix multiplication is a fundamental operation in solving systems of equations, transformations, and more.
  • Data Science: Used in statistical methods like regression and machine learning for operations involving covariance matrices or weight matrices.
Leave a Reply 0

Your email address will not be published. Required fields are marked *