Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Matrix Solver in Excel: Step-by-Step Guide

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Excel can solve systems of linear equations using its built-in matrix functions. The most reliable method is to use the MMULT and MINVERSE functions together, or the newer dynamic array functions if you have Microsoft 365. This guide shows you how to set up and solve a matrix equation of the form AX = B, where A is the coefficient matrix, X is the unknown vector, and B is the constants vector. The solution is X = A-1B. You will need Excel 2010 or later; the steps below work on both Windows and Mac, though menu labels may differ slightly by version and region.

What You'll Need

  • Microsoft Excel (any modern version; Microsoft 365 recommended for dynamic arrays)
  • A system of linear equations with the same number of equations as unknowns (a square coefficient matrix)
  • Basic familiarity with entering data and using formulas

Step-by-Step

  1. Write your equations in standard form. For example: 2x + 3y = 8 and 4x - y = 2. Identify the coefficients and constants.
  2. Enter the coefficient matrix A. In a blank worksheet, type the coefficients into a square range. For the example, select cells A1:B2 and type:
    A1: 2, B1: 3
    A2: 4, B2: -1
  3. Enter the constants vector B. In cells D1:D2, type 8 and 2 respectively.
  4. Check that A is invertible. A matrix is invertible if its determinant is not zero. In a cell, type =MDETERM(A1:B2). If the result is 0 (or very close to 0), the system has no unique solution; stop and review your equations.
  5. Compute the inverse of A. Select a 2x2 range (e.g., F1:G2), type =MINVERSE(A1:B2), and press Ctrl+Shift+Enter (Windows) or Command+Shift+Enter (Mac) if you are not on Microsoft 365. On Microsoft 365, just press Enter; the result will spill automatically.
  6. Multiply the inverse by B. Select a 2x1 range (e.g., I1:I2), type =MMULT(F1:G2, D1:D2), and press Ctrl+Shift+Enter (or Enter on Microsoft 365). The result is the solution vector X.
  7. Verify the solution. In a new cell, type =MMULT(A1:B2, I1:I2) and compare to B. They should match within rounding error.
  8. Alternative: use a single formula (Microsoft 365 only). In a cell, type =MMULT(MINVERSE(A1:B2), D1:D2) and press Enter. The result spills into adjacent cells.
  9. Alternative: use Solver for larger or non-square systems. Go to Data > Solver (enable via File > Options > Add-ins if needed). Set the objective to minimize the sum of squared residuals, or use the GRG Nonlinear engine to solve equations directly. This is more complex and beyond the scope of this guide, but it is an option for overdetermined systems.
  10. Format the results. Select the solution cells and format as Number with sufficient decimal places to see the values clearly.

Common Mistakes

  • Forgetting Ctrl+Shift+Enter. In older Excel versions, array formulas require this key combination. If you just press Enter, you may get a single value or an error.
  • Selecting the wrong output range size. MINVERSE returns a matrix the same size as the input; MMULT returns a matrix with rows from the first argument and columns from the second. Make sure your selected range matches.
  • Using a non-square matrix. MINVERSE only works on square matrices. For non-square systems, use other methods like least squares.
  • Ignoring a zero determinant. If MDETERM returns 0, the matrix is singular and cannot be inverted. Check for redundant or inconsistent equations.
  • Typing values instead of cell references. Always reference the cells containing your matrix, not the numbers themselves, so you can update easily.

Tips

  • Use named ranges (Formulas > Define Name) to make formulas easier to read, e.g., =MMULT(MINVERSE(MatrixA), VectorB).
  • For larger matrices, consider using the LINEST function or the Solver add-in for more robust solutions.
  • Always verify your solution by multiplying A by X and checking it equals B.
  • If you have Microsoft 365, dynamic arrays eliminate the need for Ctrl+Shift+Enter and make formulas simpler.
  • Use the TRANSPOSE function if you need to switch rows and columns.

Troubleshooting

  • #VALUE! error: Check that your ranges are the correct size and contain only numbers. Also ensure you entered the formula as an array formula if needed.
  • #NUM! error: This often means the matrix is singular (determinant zero) or the calculation cannot be performed. Verify the determinant.
  • Results look wrong: Double-check your matrix entries and the order of multiplication. Remember that matrix multiplication is not commutative: AB ≠ BA.
  • Formula returns a single value instead of an array: You likely forgot to select the full output range before entering the formula, or you didn't press Ctrl+Shift+Enter in older versions.
  • Solver not available: Enable it via File > Options > Add-ins > Manage Excel Add-ins > Go > check Solver Add-in.

Frequently Asked Questions

Can Excel solve a system of equations with more equations than unknowns?

Yes, but you cannot use MINVERSE because the coefficient matrix is not square. You can use the Solver add-in or the LINEST function for least-squares solutions.

What is the difference between MINVERSE and MMULT?

MINVERSE computes the inverse of a square matrix. MMULT multiplies two matrices. Together they solve AX = B as X = MINVERSE(A) * B.

Do I need to press Ctrl+Shift+Enter in Excel 365?

No. Excel 365 supports dynamic arrays, so you can just press Enter. In older versions, array formulas require Ctrl+Shift+Enter.

Why does MDETERM return a very small number instead of zero?

Floating-point precision can cause tiny non-zero values. If the determinant is extremely small (e.g., 1E-15), treat it as zero and check your equations.

Can I use Excel to solve a 3x3 or larger system?

Yes, the same method works for any square matrix size. Just select ranges of the appropriate size and enter the formulas as array formulas.

Is there a built-in matrix solver in Excel?

Excel does not have a single "solve" button for matrices, but the combination of MINVERSE and MMULT effectively solves linear systems. The Solver add-in can also be used for more complex problems.