Algebra Calculators

##### Related Content

Programmers and Teachers:

# Matrix Multiplication Calculator

Get unlimited calculations here.

## Lesson on Matrix Multiplication

#### Lesson Contents

### Rules of Multiplication

Matrix multiplication adheres to different rules than matrix addition and subtraction. **When multiplying a matrix by another matrix, the number of columns in the first matrix must match the number of rows in the second matrix.** The first matrix may have any number of rows and the second matrix may have any number of columns.

The output matrix dimensions are defined by the dimensions of the input matrices. The formula for such is given as:**m×n x n×p → m×p**

Where matrix A is of dimensions m×n, matrix B is of dimensions n×p, and matrix C is of dimensions m×p.

### How to Multiply a Matrix by Another Matrix

**To multiply two matrices, we perform the dot product of rows and columns from matrix A and matrix B respectively.** Consider each row of matrix A a vector with a number of components equal to the number of columns *n*. Then, consider each column of matrix B a vector with a number of components equal to the number of rows *n*.

Below is a literal example of using dot products to multiply a 3×2 matrix *A* by a 2×3 matrix *B*.

## How the Calculator Works

The calculator on this page is written in the programming language JavaScript (JS) and runs in your device’s internet browser JS engine, allowing for near-instant solutions at the click of a button. The code follows the same rules and steps as outlined in this lesson, with some additional steps and processes.

When the calculate button is clicked, a function is activated that contains several nested loops. The first loops create variables for each entry of matrix A and matrix B. Then, another set of loops create the output matrix C while performing the respective dot products of the entries from A and B. The final loop converts the output matrix into LaTeX, a math rendering language.

Once calculations finish, the LaTeX code of the output matrix is rendered in the answer area of the calculator. Sometimes the inputs cause an error or do not allow for a solution to be found. When these anomalies occur, an error statement is displayed instead of an answer.