{
  "id": "rref",
  "version": "e6b23f16650e",
  "status": "published",
  "name": "RREF Calculator",
  "question": "What is the RREF of this matrix?",
  "summary": "Reduces a matrix to reduced row echelon form (RREF) by Gauss-Jordan elimination in exact fractions, with the rank, the pivot columns, and every row operation.",
  "category": "math",
  "subcategory": "linear-algebra",
  "url": "https://www.acalculator.org/math/rref-calculator",
  "markdown": "https://www.acalculator.org/math/rref-calculator.md",
  "kind": "function",
  "method": "Gauss-Jordan elimination: for each column from the left, take the first remaining row with a nonzero entry as the pivot row, swap it up, scale it so the pivot is 1, and subtract multiples of it from every other row so the rest of the column is 0.",
  "assumptions": [
    "Every entry is read as an exact fraction: a decimal such as 0.1 is 1/10, so there is no rounding in the elimination.",
    "The pivot is the first row, from the top of the remaining rows, with a nonzero entry in the column. Other valid orders of row operations give the same RREF.",
    "The matrix has 1 to 10 rows and 1 to 10 columns."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "m": {
        "title": "Matrix",
        "description": "The matrix to reduce, 1 to 10 rows and columns. For a system of equations, the last column holds the constants.",
        "type": "array",
        "items": {
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      }
    }
  },
  "outputs": {
    "rref": {
      "label": "RREF",
      "description": "The reduced row echelon form as exact fractions, rows separated by semicolons.",
      "format": "text"
    },
    "decimal": {
      "label": "RREF in decimals",
      "description": "The same matrix in decimals, each number rounded to 10 significant figures.",
      "format": "text"
    },
    "rank": {
      "label": "Rank",
      "description": "The number of pivots (leading 1s).",
      "format": "integer"
    },
    "pivots": {
      "label": "Pivot columns",
      "description": "The columns that hold a leading 1, counted from 1.",
      "format": "text"
    },
    "free": {
      "label": "Columns without a pivot",
      "description": "The columns with no leading 1: the free variables of a homogeneous system, counted from 1.",
      "format": "text"
    },
    "steps": {
      "label": "Row operations",
      "description": "Every row operation, in order: swap two rows, scale a row, or add a multiple of one row to another.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "m": [
        [
          1,
          2,
          3
        ],
        [
          4,
          5,
          6
        ],
        [
          7,
          8,
          9
        ]
      ]
    },
    "outputs": {
      "rref": "[1, 0, -1; 0, 1, 2; 0, 0, 0]",
      "decimal": "[1, 0, -1; 0, 1, 2; 0, 0, 0]",
      "rank": 2,
      "pivots": "1, 2",
      "free": "3",
      "steps": "R2 → R2 − 4 × R1; R3 → R3 − 7 × R1; R2 → -1/3 × R2; R1 → R1 − 2 × R2; R3 → R3 + 6 × R2"
    },
    "text": "The reduced row echelon form is [1, 0, -1; 0, 1, 2; 0, 0, 0], with rank 2."
  },
  "examples": [
    {
      "given": {
        "m": [
          [
            1,
            2,
            3
          ],
          [
            4,
            5,
            6
          ],
          [
            7,
            8,
            9
          ]
        ]
      },
      "expect": {
        "rref": "[1, 0, -1; 0, 1, 2; 0, 0, 0]",
        "rank": 2,
        "pivots": "1, 2",
        "free": "3"
      },
      "source": "hand calculation in content.mdx; MIT OpenCourseWare 18.06 Linear Algebra (Gilbert Strang), Lecture 7: Solving Ax = 0, pivot variables, special solutions (reduced row echelon form). https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/resources/lecture-7-solving-ax-0-pivot-variables-special-solutions/"
    },
    {
      "given": {
        "m": [
          [
            1,
            1,
            1,
            6
          ],
          [
            0,
            2,
            5,
            -4
          ],
          [
            2,
            5,
            -1,
            27
          ]
        ]
      },
      "expect": {
        "rref": "[1, 0, 0, 5; 0, 1, 0, 3; 0, 0, 1, -2]",
        "rank": 3,
        "pivots": "1, 2, 3",
        "free": "4"
      },
      "source": "hand calculation in content.mdx; solution x = 5, y = 3, z = −2 checked by substitution; MIT OpenCourseWare 18.06 Linear Algebra (Gilbert Strang), Lecture 7: Solving Ax = 0, pivot variables, special solutions (reduced row echelon form). https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/resources/lecture-7-solving-ax-0-pivot-variables-special-solutions/"
    },
    {
      "given": {
        "m": [
          [
            1,
            3,
            -2,
            0,
            2,
            0,
            0
          ],
          [
            2,
            6,
            -5,
            -2,
            4,
            -3,
            -1
          ],
          [
            0,
            0,
            5,
            10,
            0,
            15,
            5
          ],
          [
            2,
            6,
            0,
            8,
            4,
            18,
            6
          ]
        ]
      },
      "expect": {
        "rref": "[1, 3, 0, 4, 2, 0, 0; 0, 0, 1, 2, 0, 0, 0; 0, 0, 0, 0, 0, 1, 1/3; 0, 0, 0, 0, 0, 0, 0]",
        "rank": 3,
        "pivots": "1, 3, 6",
        "free": "2, 4, 5, 7"
      },
      "source": "Anton, Elementary Linear Algebra, section 1.2 (Gauss-Jordan elimination example); Python fractions check in docs/progress/WP-25.md; MIT OpenCourseWare 18.06 Linear Algebra (Gilbert Strang), Lecture 7: Solving Ax = 0, pivot variables, special solutions (reduced row echelon form). https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/resources/lecture-7-solving-ax-0-pivot-variables-special-solutions/"
    },
    {
      "given": {
        "m": [
          [
            0.1,
            0.2,
            0.3
          ],
          [
            0.4,
            0.5,
            0.6
          ]
        ]
      },
      "expect": {
        "rref": "[1, 0, -1; 0, 1, 2]",
        "rank": 2,
        "steps": "R1 → 10 × R1; R2 → R2 − 2/5 × R1; R2 → -10/3 × R2; R1 → R1 − 2 × R2"
      },
      "source": "hand calculation in content.mdx: decimals are read exactly (0.1 is 1/10); MIT OpenCourseWare 18.06 Linear Algebra (Gilbert Strang), Lecture 7: Solving Ax = 0, pivot variables, special solutions (reduced row echelon form). https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/resources/lecture-7-solving-ax-0-pivot-variables-special-solutions/"
    },
    {
      "given": {
        "m": [
          [
            0,
            0
          ],
          [
            0,
            0
          ]
        ]
      },
      "expect": {
        "rref": "[0, 0; 0, 0]",
        "rank": 0,
        "pivots": "none",
        "free": "1, 2",
        "steps": "none: the matrix is already in RREF"
      },
      "source": "definition of RREF: a zero matrix has no pivots and is already reduced (Anton, Elementary Linear Algebra, section 1.2); MIT OpenCourseWare 18.06 Linear Algebra (Gilbert Strang), Lecture 7: Solving Ax = 0, pivot variables, special solutions (reduced row echelon form). https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/resources/lecture-7-solving-ax-0-pivot-variables-special-solutions/"
    }
  ],
  "sources": [
    "MIT OpenCourseWare 18.06 Linear Algebra (Gilbert Strang), Lecture 7: Solving Ax = 0, pivot variables, special solutions (reduced row echelon form). https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/resources/lecture-7-solving-ax-0-pivot-variables-special-solutions/"
  ],
  "related": [],
  "changelog": [
    {
      "date": "2026-09-29",
      "note": "Worked examples name a published reference for their rule."
    }
  ]
}
