Products
  • Wolfram|One

    The definitive Wolfram Language and notebook experience

  • Mathematica

    The original technical computing environment

  • Notebook Assistant + LLM Kit

    All-in-one AI assistance for your Wolfram experience

  • Compute Services
  • System Modeler
  • Finance Platform
  • Wolfram|Alpha Notebook Edition
  • Application Server
  • Enterprise Private Cloud
  • Wolfram Engine
  • Wolfram Player
  • Wolfram Cloud App
  • Wolfram Player App

More mobile apps

Core Technologies of Wolfram Products

  • Wolfram Language
  • Computable Data
  • Wolfram Notebooks
  • AI & Linguistic Understanding

Deployment Options

  • Wolfram Cloud
  • wolframscript
  • Wolfram Engine Community Edition
  • Wolfram LLM API
  • WSTPServer
  • Wolfram|Alpha APIs

From the Community

  • Function Repository
  • Community Paclet Repository
  • Example Repository
  • Neural Net Repository
  • Prompt Repository
  • Wolfram Demonstrations
  • Data Repository
  • Group & Organizational Licensing
  • All Products
Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

  • Data & Computational Intelligence
  • Model-Based Design
  • Algorithm Development
  • Wolfram|Alpha for Business
  • Blockchain Technology
  • Education Technology
  • Quantum Computation

Wolfram Consulting

Wolfram Solutions

  • Data Science
  • Artificial Intelligence
  • Biosciences
  • Healthcare Intelligence
  • Sustainable Energy
  • Control Systems
  • Enterprise Wolfram|Alpha
  • Blockchain Labs

More Wolfram Solutions

Wolfram Solutions For Education

  • Research Universities
  • Colleges & Teaching Universities
  • Junior & Community Colleges
  • High Schools
  • Educational Technology
  • Computer-Based Math

More Solutions for Education

  • Contact Us
Learning & Support

Get Started

  • Wolfram Language Introduction
  • Fast Intro for Programmers
  • Fast Intro for Math Students
  • Wolfram Language Documentation

More Learning

  • Highlighted Core Areas
  • Demonstrations
  • YouTube
  • Daily Study Groups
  • Wolfram Schools and Programs
  • Books

Grow Your Skills

  • Wolfram U

    Courses in computing, science, life and more

  • Community

    Learn, solve problems and share ideas.

  • Blog

    News, views and insights from Wolfram

  • Resources for

    Software Developers

Tech Support

  • Contact Us
  • Support FAQs
  • Support FAQs
  • Contact Us
Company
  • About Wolfram
  • Career Center
  • All Sites & Resources
  • Connect & Follow
  • Contact Us

Work with Us

  • Student Ambassador Initiative
  • Wolfram for Startups
  • Student Opportunities
  • Jobs Using Wolfram Language

Educational Programs for Adults

  • Summer School
  • Winter School

Educational Programs for Youth

  • Middle School Camp
  • High School Research Program
  • Computational Adventures

Read

  • Stephen Wolfram's Writings
  • Wolfram Blog
  • Wolfram Tech | Books
  • Wolfram Media
  • Complex Systems

Educational Resources

  • Wolfram MathWorld
  • Wolfram in STEM/STEAM
  • Wolfram Challenges
  • Wolfram Problem Generator

Wolfram Initiatives

  • Wolfram Science
  • Wolfram Foundation
  • History of Mathematics Project

Events

  • Stephen Wolfram Livestreams
  • Online & In-Person Events
  • Contact Us
  • Connect & Follow
Wolfram|Alpha
  • Your Account
  • User Portal
  • Wolfram Cloud
  • Products
    • Wolfram|One
    • Mathematica
    • Notebook Assistant + LLM Kit
    • Compute Services
    • System Modeler
    • Finance Platform
    • Wolfram|Alpha Notebook Edition
    • Application Server
    • Enterprise Private Cloud
    • Wolfram Engine
    • Wolfram Player
    • Wolfram Cloud App
    • Wolfram Player App

    More mobile apps

    • Core Technologies
      • Wolfram Language
      • Computable Data
      • Wolfram Notebooks
      • AI & Linguistic Understanding
    • Deployment Options
      • Wolfram Cloud
      • wolframscript
      • Wolfram Engine Community Edition
      • Wolfram LLM API
      • WSTPServer
      • Wolfram|Alpha APIs
    • From the Community
      • Function Repository
      • Community Paclet Repository
      • Example Repository
      • Neural Net Repository
      • Prompt Repository
      • Wolfram Demonstrations
      • Data Repository
    • Group & Organizational Licensing
    • All Products
  • Consulting & Solutions

    We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

    WolframConsulting.com

    Wolfram Solutions

    • Data Science
    • Artificial Intelligence
    • Biosciences
    • Healthcare Intelligence
    • Sustainable Energy
    • Control Systems
    • Enterprise Wolfram|Alpha
    • Blockchain Labs

    More Wolfram Solutions

    Wolfram Solutions For Education

    • Research Universities
    • Colleges & Teaching Universities
    • Junior & Community Colleges
    • High Schools
    • Educational Technology
    • Computer-Based Math

    More Solutions for Education

    • Contact Us
  • Learning & Support

    Get Started

    • Wolfram Language Introduction
    • Fast Intro for Programmers
    • Fast Intro for Math Students
    • Wolfram Language Documentation

    Grow Your Skills

    • Wolfram U

      Courses in computing, science, life and more

    • Community

      Learn, solve problems and share ideas.

    • Blog

      News, views and insights from Wolfram

    • Resources for

      Software Developers
    • Tech Support
      • Contact Us
      • Support FAQs
    • More Learning
      • Highlighted Core Areas
      • Demonstrations
      • YouTube
      • Daily Study Groups
      • Wolfram Schools and Programs
      • Books
    • Support FAQs
    • Contact Us
  • Company
    • About Wolfram
    • Career Center
    • All Sites & Resources
    • Connect & Follow
    • Contact Us

    Work with Us

    • Student Ambassador Initiative
    • Wolfram for Startups
    • Student Opportunities
    • Jobs Using Wolfram Language

    Educational Programs for Adults

    • Summer School
    • Winter School

    Educational Programs for Youth

    • Middle School Camp
    • High School Research Program
    • Computational Adventures

    Read

    • Stephen Wolfram's Writings
    • Wolfram Blog
    • Wolfram Tech | Books
    • Wolfram Media
    • Complex Systems
    • Educational Resources
      • Wolfram MathWorld
      • Wolfram in STEM/STEAM
      • Wolfram Challenges
      • Wolfram Problem Generator
    • Wolfram Initiatives
      • Wolfram Science
      • Wolfram Foundation
      • History of Mathematics Project
    • Events
      • Stephen Wolfram Livestreams
      • Online & In-Person Events
    • Contact Us
    • Connect & Follow
  • Wolfram|Alpha
  • Wolfram Cloud
  • Your Account
  • User Portal
Wolfram Language & System Documentation Center
QRDecomposition
  • See Also
    • SchurDecomposition
    • LUDecomposition
    • SingularValueDecomposition
    • JordanDecomposition
    • CholeskyDecomposition
    • HessenbergDecomposition
    • Orthogonalize
  • Related Guides
    • Matrix Decompositions
    • Matrices and Linear Algebra
    • Matrix-Based Minimization
  • Tech Notes
    • Advanced Matrix Operations
    • Implementation Notes: Numerical and Related Functions
    • See Also
      • SchurDecomposition
      • LUDecomposition
      • SingularValueDecomposition
      • JordanDecomposition
      • CholeskyDecomposition
      • HessenbergDecomposition
      • Orthogonalize
    • Related Guides
      • Matrix Decompositions
      • Matrices and Linear Algebra
      • Matrix-Based Minimization
    • Tech Notes
      • Advanced Matrix Operations
      • Implementation Notes: Numerical and Related Functions

QRDecomposition[m]

yields the QR decomposition for a numerical matrix m. The result is a list {q,r}, where q is a unitary matrix and r is an upper‐triangular matrix.

Details and Options
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Basic Uses  
Special Matrices  
Options  
Pivoting  
TargetStructure  
Applications  
Geometry of QRDecomposition  
Least Squares and Curve Fitting  
Properties & Relations  
See Also
Tech Notes
Related Guides
History
Cite this Page
BUILT-IN SYMBOL
  • See Also
    • SchurDecomposition
    • LUDecomposition
    • SingularValueDecomposition
    • JordanDecomposition
    • CholeskyDecomposition
    • HessenbergDecomposition
    • Orthogonalize
  • Related Guides
    • Matrix Decompositions
    • Matrices and Linear Algebra
    • Matrix-Based Minimization
  • Tech Notes
    • Advanced Matrix Operations
    • Implementation Notes: Numerical and Related Functions
    • See Also
      • SchurDecomposition
      • LUDecomposition
      • SingularValueDecomposition
      • JordanDecomposition
      • CholeskyDecomposition
      • HessenbergDecomposition
      • Orthogonalize
    • Related Guides
      • Matrix Decompositions
      • Matrices and Linear Algebra
      • Matrix-Based Minimization
    • Tech Notes
      • Advanced Matrix Operations
      • Implementation Notes: Numerical and Related Functions

QRDecomposition

QRDecomposition[m]

yields the QR decomposition for a numerical matrix m. The result is a list {q,r}, where q is a unitary matrix and r is an upper‐triangular matrix.

Details and Options

  • The original matrix m is equal to ConjugateTranspose[q].r. »
  • For non‐square matrices, q is row orthonormal. »
  • The matrix r has zeros for all entries below the leading diagonal. »
  • With the setting TargetStructure->"Structured", QRDecomposition[m] returns the matrices {q,r} as structured matrices.
  • QRDecomposition[m,Pivoting->True] yields a list {q,r,p} where p is a permutation matrix such that m.p is equal to ConjugateTranspose[q].r. »

Examples

open all close all

Basic Examples  (3)

The decomposition of a 2×2 matrix into a unitary (orthogonal) matrix and upper triangular matrix :

Verify that m=TemplateBox[{q}, ConjugateTranspose].r:

Compute the QR decomposition for a 3×2 matrix with exact values:

TemplateBox[{q}, Transpose].r is the original matrix:

Compute the QR decomposition for a 2×3 matrix with approximate numerical values:

TemplateBox[{q}, Transpose].r is the original matrix:

Scope  (11)

Basic Uses  (7)

Find the QR decomposition of a machine-precision matrix:

Format the result:

QR decomposition for a complex matrix:

Use QRDecomposition for an exact matrix:

QR decomposition for an arbitrary-precision matrix:

Use QRDecomposition with a symbolic matrix:

The QR decomposition for a large numerical matrix is computed efficiently:

QR decomposition of a non-square matrix:

Special Matrices  (4)

Find the QR decomposition for a sparse matrix:

QR decompositions of structured matrices:

Use with a QuantityArray structured matrix that has consistent units:

The matrix is dimensionless; the matrix gets the units:

QR decomposition of an IdentityMatrix consists of two identity matrices:

QR decomposition of HilbertMatrix:

Options  (4)

Pivoting  (1)

Compute the QR decomposition using machine arithmetic with pivoting:

The elements along the diagonal of r are in order of decreasing magnitude:

The matrix p is a permutation matrix:

QRDecomposition satisfies m.p==ConjugateTranspose[q].r:

TargetStructure  (3)

A real rectangular matrix:

With TargetStructure->"Dense", the result of QRDecomposition is a list of two dense matrices:

With TargetStructure->"Structured", the result of QRDecomposition is a list containing an OrthogonalMatrix and an UpperTriangularMatrix:

A real rectangular matrix:

With the settings Pivoting->True and TargetStructure->"Structured", the result of QRDecomposition is a list containing an OrthogonalMatrix, an UpperTriangularMatrix and a PermutationMatrix:

A complex rectangular matrix:

With TargetStructure->"Dense", the result of QRDecomposition is a list of two dense matrices:

With TargetStructure->"Structured", the result of QRDecomposition is a list containing a UnitaryMatrix and an UpperTriangularMatrix:

Applications  (8)

Geometry of QRDecomposition  (4)

Find an orthonormal basis for the column space of the following matrix , and then use that basis to find a QR factorization of :

Compute the dimensions of :

Define as the column of and as the element of the corresponding Gram–Schmidt basis:

Let be the matrix whose rows are the :

Let be the matrix whose elements are the components of along the basis vector:

Confirm that :

This is the same result as given by QRDecomposition:

Compare QR decompositions found using Orthogonalize and QRDecomposition for the following matrix :

Let be the result of applying Orthogonalize to the columns of :

Let equal :

Confirm that :

This is the same result as given by QRDecomposition:

Compare QR decompositions found using Orthogonalize and QRDecomposition for the following matrix :

Let be the result of applying Orthogonalize to the complex-conjugated columns of :

Let equal :

Confirm that :

Up to sign, this is the same result as given by QRDecomposition:

For some applications, it use useful to compute a so-called full QR decomposition, in which the is square (and thus unitary) and has the same dimensions as the input matrix. Compute the full QR decomposition for the following matrix :

There are only two linearly independent columns, so and each have only two rows:

Use NullSpace to find vectors outside the span of the rows of , then orthogonalize the complete set:

This matrix is unitary:

Simply pad the matrix with zeros to make it the same shape as :

Verify that this is also a valid QR decomposition:

Least Squares and Curve Fitting  (4)

Use the QR decomposition to find the that minimizes TemplateBox[{{{m, ., x}, -, b}}, Norm] for the following matrix and vector :

Compute decomposition of :

Since m=TemplateBox[{q}, Transpose].r, TemplateBox[{m}, Transpose].m=TemplateBox[{r}, Transpose].r, and the normal equations TemplateBox[{m}, Transpose].m.x=TemplateBox[{m}, Transpose].b can be recast as TemplateBox[{r}, Transpose].r.x=TemplateBox[{r}, Transpose].q.b:

As is invertible (because the columns of are linearly independent), the solution is x=TemplateBox[{r}, Inverse].q.b:

Confirm the result using LeastSquares:

Use the QR decomposition to solve for the following matrix and vector :

Compute the QR decomposition of TemplateBox[{m}, Transpose], which gives an invertible , as has linearly independent rows:

Let x=TemplateBox[{q}, Transpose].TemplateBox[{{(, TemplateBox[{r}, Transpose, SyntaxForm -> SuperscriptBox], )}}, Inverse].b as if solving the least-squares problem:

As the columns of span TemplateBox[{}, Reals]^3, must be a solution of the equation:

QRDecomposition can be used to find a best-fit curve to data. Consider the following data:

Extract the and coordinates from the data:

Let have the columns and , so that minimizing TemplateBox[{{{m, ., {{, {a, ,, b}, }}}, -, y}}, Norm] will be fitting to a line :

As the columns of are linearly independent, the coefficients for a linear least‐squares fit are TemplateBox[{r}, Inverse].q.y:

Verify the coefficients using Fit:

Plot the best-fit curve along with the data:

Find the best-fit parabola to the following data:

Extract the and coordinates from the data:

Let have the columns , and , so that minimizing TemplateBox[{{{m, ., {{, {a, ,, b, ,, c}, }}}, -, y}}, Norm] will be fitting to :

As the columns of are linearly independent, the coefficients for a least‐squares fit are TemplateBox[{r}, Inverse].q.y:

Verify the coefficients using Fit:

Plot the best-fit curve along with the data:

Properties & Relations  (10)

m is a 3×4 matrix:

Compute the QR decomposition:

The rows of q are orthonormal:

r is upper triangular:

m is equal to ConjugateTranspose[q].r:

If is an matrix, the matrix will have columns and the matrix columns:

QRDecomposition computes the "thin" decomposition, where and have MatrixRank[m] rows:

If m is real-valued and invertible, the matrix of its QR decomposition is orthogonal:

If m is invertible, the matrix of its QR decomposition is unitary:

If a is an matrix and MatrixRank[a]==n, the matrix of its QR decomposition is unitary:

If a is an matrix and MatrixRank[a]==m, the matrix of its QR decomposition is invertible:

Moreover, PseudoInverse[a]==Inverse[r].q:

Orthogonalize can be used to compute a QR decomposition:

For an approximate matrix, it is typically different from the one found by QRDecomposition:

LeastSquares and QRDecomposition can both be used to solve the least-squares problem:

The Cholesky decomposition of TemplateBox[{m}, ConjugateTranspose].m coincides with 's QR decomposition up to phase:

Compute CholeskyDecomposition[ConjugateTranspose[m].]m:

Find the QR decomposition of :

is the same as except for the choice of phase for each row:

See Also

SchurDecomposition  LUDecomposition  SingularValueDecomposition  JordanDecomposition  CholeskyDecomposition  HessenbergDecomposition  Orthogonalize

Function Repository: FullQRDecomposition  PolarDecomposition

Tech Notes

    ▪
  • Advanced Matrix Operations
  • ▪
  • Implementation Notes: Numerical and Related Functions

Related Guides

    ▪
  • Matrix Decompositions
  • ▪
  • Matrices and Linear Algebra
  • ▪
  • Matrix-Based Minimization

History

Introduced in 1991 (2.0) | Updated in 2024 (14.0)

Wolfram Research (1991), QRDecomposition, Wolfram Language function, https://reference.wolfram.com/language/ref/QRDecomposition.html (updated 2024).

Text

Wolfram Research (1991), QRDecomposition, Wolfram Language function, https://reference.wolfram.com/language/ref/QRDecomposition.html (updated 2024).

CMS

Wolfram Language. 1991. "QRDecomposition." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/QRDecomposition.html.

APA

Wolfram Language. (1991). QRDecomposition. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/QRDecomposition.html

BibTeX

@misc{reference.wolfram_2025_qrdecomposition, author="Wolfram Research", title="{QRDecomposition}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/QRDecomposition.html}", note=[Accessed: 01-March-2026]}

BibLaTeX

@online{reference.wolfram_2025_qrdecomposition, organization={Wolfram Research}, title={QRDecomposition}, year={2024}, url={https://reference.wolfram.com/language/ref/QRDecomposition.html}, note=[Accessed: 01-March-2026]}

Top
Introduction for Programmers
Introductory Book
Wolfram Function Repository | Wolfram Data Repository | Wolfram Data Drop | Wolfram Language Products
Top
  • Products
  • Wolfram|One
  • Mathematica
  • Notebook Assistant + LLM Kit
  • Compute Services
  • System Modeler

  • Wolfram|Alpha Notebook Edition
  • Wolfram|Alpha Pro
  • Mobile Apps

  • Wolfram Engine
  • Wolfram Player

  • Volume & Site Licensing
  • Server Deployment Options
  • Consulting
  • Wolfram Consulting
  • Repositories
  • Data Repository
  • Function Repository
  • Community Paclet Repository
  • Neural Net Repository
  • Prompt Repository

  • Wolfram Language Example Repository
  • Notebook Archive
  • Wolfram GitHub
  • Learning
  • Wolfram U
  • Wolfram Language Documentation
  • Webinars & Training
  • Educational Programs

  • Wolfram Language Introduction
  • Fast Introduction for Programmers
  • Fast Introduction for Math Students
  • Books

  • Wolfram Community
  • Wolfram Blog
  • Public Resources
  • Wolfram|Alpha
  • Wolfram Problem Generator
  • Wolfram Challenges

  • Computer-Based Math
  • Computational Thinking
  • Computational Adventures

  • Demonstrations Project
  • Wolfram Data Drop
  • MathWorld
  • Wolfram Science
  • Wolfram Media Publishing
  • Customer Resources
  • Store
  • Product Downloads
  • User Portal
  • Your Account
  • Organization Access

  • Support FAQ
  • Contact Support
  • Company
  • About Wolfram
  • Careers
  • Contact
  • Events
Wolfram Community Wolfram Blog
Legal & Privacy Policy
WolframAlpha.com | WolframCloud.com
© 2026 Wolfram
© 2026 Wolfram | Legal & Privacy Policy |
English