{
  "id": "gram-schmidt",
  "version": "81653ef80ba1",
  "status": "published",
  "name": "Gram-Schmidt Calculator",
  "question": "What is the Gram-Schmidt basis?",
  "summary": "Runs the Gram-Schmidt process on up to 10 linearly independent vectors: the orthogonal vectors u₁, u₂, … and the orthonormal basis e₁, e₂, … that spans the same space, with the working.",
  "category": "math",
  "subcategory": "linear-algebra",
  "url": "https://www.acalculator.org/math/gram-schmidt-calculator",
  "markdown": "https://www.acalculator.org/math/gram-schmidt-calculator.md",
  "kind": "function",
  "method": "u₁ = v₁; uₖ = vₖ − Σⱼ₍ⱼ₌₁…ₖ₋₁₎ (vₖ·eⱼ)eⱼ; eₖ = uₖ ÷ |uₖ|.",
  "assumptions": [
    "The vectors are real and linearly independent. A zero vector, or a vector that is a combination of the earlier ones, has no answer.",
    "Vectors are processed in the order given; another order gives a different orthonormal basis of the same space.",
    "A vector counts as dependent when the part of it outside the span of the earlier vectors is at most 10⁻¹⁰ of its length."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "v": {
        "title": "Vectors (one per row)",
        "description": "The vectors v₁, v₂, …, one per row: 1 to 10 vectors of dimension 1 to 10.",
        "type": "array",
        "items": {
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      }
    }
  },
  "outputs": {
    "basis": {
      "label": "Orthonormal basis",
      "description": "The unit vectors e₁, e₂, … as rows separated by semicolons, rounded to 10 significant figures.",
      "format": "text"
    },
    "u1": {
      "label": "u1",
      "description": "Orthogonal vector 1: v1 minus its projections onto the earlier unit vectors.",
      "format": "text"
    },
    "u2": {
      "label": "u2",
      "description": "Orthogonal vector 2: v2 minus its projections onto the earlier unit vectors.",
      "format": "text"
    },
    "u3": {
      "label": "u3",
      "description": "Orthogonal vector 3: v3 minus its projections onto the earlier unit vectors.",
      "format": "text"
    },
    "u4": {
      "label": "u4",
      "description": "Orthogonal vector 4: v4 minus its projections onto the earlier unit vectors.",
      "format": "text"
    },
    "u5": {
      "label": "u5",
      "description": "Orthogonal vector 5: v5 minus its projections onto the earlier unit vectors.",
      "format": "text"
    },
    "u6": {
      "label": "u6",
      "description": "Orthogonal vector 6: v6 minus its projections onto the earlier unit vectors.",
      "format": "text"
    },
    "u7": {
      "label": "u7",
      "description": "Orthogonal vector 7: v7 minus its projections onto the earlier unit vectors.",
      "format": "text"
    },
    "u8": {
      "label": "u8",
      "description": "Orthogonal vector 8: v8 minus its projections onto the earlier unit vectors.",
      "format": "text"
    },
    "u9": {
      "label": "u9",
      "description": "Orthogonal vector 9: v9 minus its projections onto the earlier unit vectors.",
      "format": "text"
    },
    "u10": {
      "label": "u10",
      "description": "Orthogonal vector 10: v10 minus its projections onto the earlier unit vectors.",
      "format": "text"
    },
    "steps": {
      "label": "Working",
      "description": "Each uᵢ as vᵢ minus its projections, then eᵢ = uᵢ ÷ |uᵢ|.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "v": [
        [
          0,
          3,
          4
        ],
        [
          1,
          0,
          1
        ],
        [
          1,
          1,
          3
        ]
      ]
    },
    "outputs": {
      "basis": "[0, 0.6, 0.8; 0.8574929257, -0.4115966043, 0.3086974533; -0.5144957554, -0.6859943406, 0.5144957554]",
      "u1": "[0, 3, 4]",
      "u2": "[1, -0.48, 0.36]",
      "u3": "[-0.1764705882, -0.2352941176, 0.1764705882]",
      "steps": "u1 = v1 = [0, 3, 4], |u1| = 5, e1 = [0, 0.6, 0.8]; u2 = v2 − (0.8)e1 = [1, -0.48, 0.36], |u2| = 1.166190379, e2 = [0.8574929257, -0.4115966043, 0.3086974533]; u3 = v3 − (3)e1 − (1.371988681)e2 = [-0.1764705882, -0.2352941176, 0.1764705882], |u3| = 0.3429971703, e3 = [-0.5144957554, -0.6859943406, 0.5144957554]"
    },
    "text": "The orthonormal basis is [0, 0.6, 0.8; 0.8574929257, -0.4115966043, 0.3086974533; -0.5144957554, -0.6859943406, 0.5144957554]."
  },
  "examples": [
    {
      "given": {
        "v": [
          [
            0,
            3,
            4
          ],
          [
            1,
            0,
            1
          ],
          [
            1,
            1,
            3
          ]
        ]
      },
      "expect": {
        "basis": "[0, 0.6, 0.8; 0.8574929257, -0.4115966043, 0.3086974533; -0.5144957554, -0.6859943406, 0.5144957554]",
        "u1": "[0, 3, 4]",
        "u2": "[1, -0.48, 0.36]",
        "u3": "[-0.1764705882, -0.2352941176, 0.1764705882]"
      },
      "source": "hand calculation in content.mdx (the old page credits this example to eMathHelp); MIT OpenCourseWare 18.06 Linear Algebra (Gilbert Strang), Lecture 17: Orthogonal Matrices and Gram-Schmidt. https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/resources/lecture-17-orthogonal-matrices-and-gram-schmidt/"
    },
    {
      "given": {
        "v": [
          [
            1,
            1
          ],
          [
            1,
            0
          ]
        ]
      },
      "expect": {
        "basis": "[0.7071067812, 0.7071067812; 0.7071067812, -0.7071067812]",
        "u2": "[0.5, -0.5]"
      },
      "source": "hand calculation in content.mdx: u₂ = (1, 0) − ½(1, 1) = (½, −½); MIT OpenCourseWare 18.06 Linear Algebra (Gilbert Strang), Lecture 17: Orthogonal Matrices and Gram-Schmidt. https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/resources/lecture-17-orthogonal-matrices-and-gram-schmidt/"
    },
    {
      "given": {
        "v": [
          [
            1,
            2,
            3,
            4
          ],
          [
            4,
            3,
            2,
            1
          ]
        ]
      },
      "expect": {
        "u2": "[3.333333333, 1.666666667, 0, -1.666666667]",
        "basis": "[0.1825741858, 0.3651483717, 0.5477225575, 0.7302967433; 0.8164965809, 0.4082482905, 0, -0.4082482905]"
      },
      "source": "hand calculation in content.mdx: v₂·v₁ / v₁·v₁ = 20/30 = 2/3; MIT OpenCourseWare 18.06 Linear Algebra (Gilbert Strang), Lecture 17: Orthogonal Matrices and Gram-Schmidt. https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/resources/lecture-17-orthogonal-matrices-and-gram-schmidt/"
    },
    {
      "given": {
        "v": [
          [
            2,
            0,
            0
          ],
          [
            3,
            4,
            0
          ],
          [
            5,
            6,
            7
          ]
        ]
      },
      "expect": {
        "basis": "[1, 0, 0; 0, 1, 0; 0, 0, 1]",
        "u2": "[0, 4, 0]",
        "u3": "[0, 0, 7]"
      },
      "source": "hand calculation in content.mdx: each vᵢ adds one new axis; MIT OpenCourseWare 18.06 Linear Algebra (Gilbert Strang), Lecture 17: Orthogonal Matrices and Gram-Schmidt. https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/resources/lecture-17-orthogonal-matrices-and-gram-schmidt/"
    },
    {
      "given": {
        "v": [
          [
            3,
            4,
            0
          ]
        ]
      },
      "expect": {
        "basis": "[0.6, 0.8, 0]",
        "u1": "[3, 4, 0]"
      },
      "source": "hand calculation in content.mdx: |(3, 4, 0)| = 5; MIT OpenCourseWare 18.06 Linear Algebra (Gilbert Strang), Lecture 17: Orthogonal Matrices and Gram-Schmidt. https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/resources/lecture-17-orthogonal-matrices-and-gram-schmidt/"
    }
  ],
  "sources": [
    "MIT OpenCourseWare 18.06 Linear Algebra (Gilbert Strang), Lecture 17: Orthogonal Matrices and Gram-Schmidt. https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/resources/lecture-17-orthogonal-matrices-and-gram-schmidt/"
  ],
  "related": [],
  "changelog": [
    {
      "date": "2026-09-29",
      "note": "Worked examples name a published reference for their rule."
    }
  ]
}
