LQ decomposition (HP compatible)

### 14.3.4 LQ decomposition (HP compatible)

The LQ decomposition of a matrix A is A=LQP, where L is lower triangular the same size as A (if A is not square, then ℓi,j=0 for i>j), Q is an orthogonal matrix, and P is a permutation matrix.

The LQ command finds the LQ decomposition of a matrix.

- LQ takes A, a matrix.
- LQ(A) returns a list [L,Q,P] of the matrices given by the LQ decomposition.

#### Examples

L,Q,P:=LQ([[4,0,0],[8,-4,3]])

| ⎡ ⎢ ⎢ ⎣ |
⎡ ⎢ ⎣ |
4.0 | 0.0 | 0.0
8.0 | 5.0 | −4.4408920985×10−16
| ⎤ ⎥ ⎦
| , |
⎡ ⎢ ⎢ ⎣ |
1.0 | 0.0 | 0.0
0.0 | −0.8 | 0.6
0.0 | −0.6 | −0.8
| ⎤ ⎥ ⎥ ⎦
| , |
⎡ ⎢ ⎢ ⎣ |
1 | 0 | 0
0 | 1 | 0
0 | 0 | 1
| ⎤ ⎥ ⎥ ⎦
| ⎤ ⎥ ⎥ ⎦

L,Q,P:=LQ([[24,18],[30,24]])

| ⎡ ⎢ ⎣ |
⎡ ⎢ ⎣ |
−30.0 | 0.0
−38.4 | −1.2
| ⎤ ⎥ ⎦
| , |
⎡ ⎢ ⎣ |
−0.8 | −0.6
0.6 | −0.8
| ⎤ ⎥ ⎦
| , |
⎡ ⎢ ⎣ |
1 | 0
0 | 1
| ⎤ ⎥ ⎦
| ⎤ ⎥ ⎦

In the above examples, LQ=PA.