﻿ QR – Algosim documentation
Algosim documentation: QR

# QR

Performs a QR decomposition of a matrix.

## Syntax

• `[Q, R ≔ ]QR(A)`

• `Q` and `R` are symbols

• `A` is a tall or square matrix

## Description

If `A` is a tall or a square matrix, then `QR(A)` computes a QR decomposition of `A`, that is, it finds an unitary matrix `Q` and an upper triangular matrix `R` such that `A = QR`. The result of `QR(A)` is an assignment list of length `2`, so the individual parts of the decomposition can be assigned to variables individually; the order is `Q, R`.

## Examples

`A ≔ ❨❨6, 2, 4, 5, 1❩, ❨2, 8, −3, 1, 2❩, ❨6, 3, 3, −1, 1❩, ❨7, 5, −2, 6, 9❩, ❨4, 5, 2, 1, 3❩❩`
```⎛ 6   2   4   5   1⎞
⎜ 2   8  −3   1   2⎟
⎜ 6   3   3  −1   1⎟
⎜ 7   5  −2   6   9⎟
⎝ 4   5   2   1   3⎠
```
`(Q, R) ≔ QR(A)`
```⎛   −0.50529115264     0.310828585124    −0.334775657031     0.616151788969    −0.395409501837⎞
⎜  −0.168430384213    −0.888355771064  0.000455632061288    0.0371917531747     −0.42552531721⎟
⎜   −0.50529115264     0.175560589746    −0.229723989901    −0.778433696719     −0.23479181985⎟
⎜  −0.589506344747    0.0019186949699     0.767341345217     0.084979050231     0.237580321273⎟
⎝  −0.336860768427     −0.28876359297    −0.496325699762    0.0761136471332     0.742299078907⎠

⎛ −11.874342087  −8.50573440277   −2.5264557632  −6.06349383168  −7.66358248171⎞
⎜             0  −7.39273171903   3.85369884705  0.212975141659  −2.13934489144⎟
⎜             0               0  −4.55697558397   2.66402370834   4.85350662485⎟
⎜             0               0               0   4.48237234326  0.905253992078⎟
⎝             0               0               0               0   2.88386817207⎠
```
`IsOrthogonal(Q) ∧ IsUpperTriangular(R)`
`true`
`Q⋅R`
```⎛ 6   2   4   5   1⎞
⎜ 2   8  −3   1   2⎟
⎜ 6   3   3  −1   1⎟
⎜ 7   5  −2   6   9⎟
⎝ 4   5   2   1   3⎠
```