{
  "id": "null-space",
  "version": "784ee64ed3b3",
  "status": "published",
  "name": "Null Space Calculator",
  "question": "What is the null space of this matrix?",
  "summary": "Finds a basis of the null space (kernel) of a matrix from its reduced row echelon form, in exact fractions, with the nullity, the rank, the free variables and the general solution of Ax = 0.",
  "category": "math",
  "subcategory": "linear-algebra",
  "url": "https://www.acalculator.org/math/null-space-calculator",
  "markdown": "https://www.acalculator.org/math/null-space-calculator.md",
  "kind": "function",
  "method": "Reduce A to its RREF by Gauss-Jordan elimination. For each free column j, set x_j = 1 and the other free variables to 0; each pivot variable is minus the entry of column j in its pivot row. These special solutions are a basis of the null space.",
  "assumptions": [
    "Every entry is read as an exact fraction: a decimal such as 0.1 is 1/10, so there is no rounding.",
    "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 A",
        "description": "The matrix A, 1 to 10 rows and 1 to 10 columns. The null space is every vector x with Ax = 0.",
        "type": "array",
        "items": {
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      }
    }
  },
  "outputs": {
    "basis": {
      "label": "Basis of the null space",
      "description": "One vector for each free column, as exact fractions; none when the null space is only the zero vector.",
      "format": "text"
    },
    "nullity": {
      "label": "Nullity",
      "description": "The dimension of the null space: columns minus rank.",
      "format": "integer"
    },
    "rank": {
      "label": "Rank",
      "description": "The number of pivots in the RREF.",
      "format": "integer"
    },
    "general": {
      "label": "All solutions of Ax = 0",
      "description": "Every solution, as a sum of the basis vectors times the free variables.",
      "format": "text"
    },
    "free": {
      "label": "Free variables",
      "description": "The columns without a pivot, counted from 1.",
      "format": "text"
    },
    "pivots": {
      "label": "Pivot columns",
      "description": "The columns with a leading 1 in the RREF, counted from 1.",
      "format": "text"
    },
    "rref": {
      "label": "RREF of A",
      "description": "The reduced row echelon form, rows separated by semicolons.",
      "format": "text"
    },
    "steps": {
      "label": "Steps",
      "description": "The RREF, the free variables, and each special solution.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "m": [
        [
          1,
          2,
          2,
          2
        ],
        [
          2,
          4,
          6,
          8
        ],
        [
          3,
          6,
          8,
          10
        ]
      ]
    },
    "outputs": {
      "basis": "[−2, 1, 0, 0], [2, 0, −2, 1]",
      "nullity": 2,
      "rank": 2,
      "general": "x = x₂·[−2, 1, 0, 0] + x₄·[2, 0, −2, 1]",
      "free": "x₂, x₄",
      "pivots": "1, 3",
      "rref": "[1, 2, 0, −2; 0, 0, 1, 2; 0, 0, 0, 0]",
      "steps": "RREF: [1, 2, 0, −2; 0, 0, 1, 2; 0, 0, 0, 0]; Pivot columns: 1, 3; free variables: x₂, x₄; Set x₂ = 1 and the other free variables to 0: [−2, 1, 0, 0]; Set x₄ = 1 and the other free variables to 0: [2, 0, −2, 1]; Nullity = 4 columns − rank 2 = 2"
    },
    "text": "The null space has dimension 2, with basis [−2, 1, 0, 0], [2, 0, −2, 1]."
  },
  "examples": [
    {
      "given": {
        "m": [
          [
            1,
            2,
            2,
            2
          ],
          [
            2,
            4,
            6,
            8
          ],
          [
            3,
            6,
            8,
            10
          ]
        ]
      },
      "expect": {
        "rref": "[1, 2, 0, −2; 0, 0, 1, 2; 0, 0, 0, 0]",
        "basis": "[−2, 1, 0, 0], [2, 0, −2, 1]",
        "nullity": 2,
        "rank": 2,
        "free": "x₂, x₄",
        "general": "x = x₂·[−2, 1, 0, 0] + x₄·[2, 0, −2, 1]"
      },
      "source": "Dan Margalit and Joseph Rabinoff, Interactive Linear Algebra (Georgia Institute of Technology), §2.7 Basis and Dimension (the vectors attached to the free variables in the parametric vector form of the solution set of Ax = 0 form a basis of Nul(A)) and §2.9 The Rank Theorem (rank(A) + nullity(A) = n), https://textbooks.math.gatech.edu/ila/dimension.html and https://textbooks.math.gatech.edu/ila/rank-thm.html (retrieved 2026-10-19); MIT OpenCourseWare 18.06 Linear Algebra (Gilbert Strang), Lecture 7: Solving Ax = 0: pivot variables, special solutions (reducing to the RREF R describes the null space), https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/resources/lecture-7-solving-ax-0-pivot-variables-special-solutions/ (retrieved 2026-10-19); hand calculation in content.mdx"
    },
    {
      "given": {
        "m": [
          [
            1,
            2,
            3
          ],
          [
            4,
            5,
            6
          ],
          [
            7,
            8,
            9
          ]
        ]
      },
      "expect": {
        "basis": "[1, −2, 1]",
        "nullity": 1,
        "rank": 2
      },
      "source": "Dan Margalit and Joseph Rabinoff, Interactive Linear Algebra (Georgia Institute of Technology), §2.7 Basis and Dimension (the vectors attached to the free variables in the parametric vector form of the solution set of Ax = 0 form a basis of Nul(A)) and §2.9 The Rank Theorem (rank(A) + nullity(A) = n), https://textbooks.math.gatech.edu/ila/dimension.html and https://textbooks.math.gatech.edu/ila/rank-thm.html (retrieved 2026-10-19); hand calculation in content.mdx: RREF [1, 0, −1; 0, 1, 2; 0, 0, 0], x₃ = 1 gives x₁ = 1, x₂ = −2"
    },
    {
      "given": {
        "m": [
          [
            2,
            1
          ],
          [
            1,
            3
          ]
        ]
      },
      "expect": {
        "basis": "the zero vector only, [0, 0]",
        "nullity": 0,
        "rank": 2,
        "free": "none"
      },
      "source": "Dan Margalit and Joseph Rabinoff, Interactive Linear Algebra (Georgia Institute of Technology), §2.7 Basis and Dimension (the vectors attached to the free variables in the parametric vector form of the solution set of Ax = 0 form a basis of Nul(A)) and §2.9 The Rank Theorem (rank(A) + nullity(A) = n), https://textbooks.math.gatech.edu/ila/dimension.html and https://textbooks.math.gatech.edu/ila/rank-thm.html (retrieved 2026-10-19); hand calculation in content.mdx: two pivots, no free variables"
    },
    {
      "given": {
        "m": [
          [
            1,
            1,
            1
          ]
        ]
      },
      "expect": {
        "basis": "[−1, 1, 0], [−1, 0, 1]",
        "nullity": 2
      },
      "source": "Dan Margalit and Joseph Rabinoff, Interactive Linear Algebra (Georgia Institute of Technology), §2.7 Basis and Dimension (the vectors attached to the free variables in the parametric vector form of the solution set of Ax = 0 form a basis of Nul(A)) and §2.9 The Rank Theorem (rank(A) + nullity(A) = n), https://textbooks.math.gatech.edu/ila/dimension.html and https://textbooks.math.gatech.edu/ila/rank-thm.html (retrieved 2026-10-19); hand calculation in content.mdx"
    },
    {
      "given": {
        "m": [
          [
            0.5,
            0.25
          ],
          [
            1,
            0.5
          ]
        ]
      },
      "expect": {
        "basis": "[−1/2, 1]",
        "rref": "[1, 1/2; 0, 0]"
      },
      "source": "Dan Margalit and Joseph Rabinoff, Interactive Linear Algebra (Georgia Institute of Technology), §2.7 Basis and Dimension (the vectors attached to the free variables in the parametric vector form of the solution set of Ax = 0 form a basis of Nul(A)) and §2.9 The Rank Theorem (rank(A) + nullity(A) = n), https://textbooks.math.gatech.edu/ila/dimension.html and https://textbooks.math.gatech.edu/ila/rank-thm.html (retrieved 2026-10-19); hand calculation in content.mdx: R1 → 2 × R1 gives [1, 1/2], so x₁ = −x₂/2"
    }
  ],
  "sources": [
    "Dan Margalit and Joseph Rabinoff, Interactive Linear Algebra (Georgia Institute of Technology), §2.7 Basis and Dimension: the vectors attached to the free variables in the parametric vector form of the solution set of Ax = 0 form a basis of Nul(A), retrieved 2026-10-19. https://textbooks.math.gatech.edu/ila/dimension.html",
    "Dan Margalit and Joseph Rabinoff, Interactive Linear Algebra, §2.9 The Rank Theorem: rank(A) + nullity(A) = n for a matrix with n columns, retrieved 2026-10-19. https://textbooks.math.gatech.edu/ila/rank-thm.html",
    "MIT OpenCourseWare 18.06 Linear Algebra (Gilbert Strang), Lecture 7: Solving Ax = 0: pivot variables, special solutions (elimination works for every matrix; the RREF R describes the null space), retrieved 2026-10-19. https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/resources/lecture-7-solving-ax-0-pivot-variables-special-solutions/"
  ],
  "related": [
    "rref",
    "linear-independence",
    "matrix",
    "determinant"
  ],
  "changelog": []
}
