LQ decomposition (HP compatible): LQ

### 6.49.4 LQ decomposition (HP compatible): LQ

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 one argument:
  A, a matrix.
- LQ(A) returns a list [L,Q,P] of the matrices given by the LQ decomposition.

Examples.

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

  ⎡ ⎢ ⎢ ⎣ |
  ⎛ ⎜ ⎝ |
  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
  | ⎤ ⎥ ⎥ ⎦ | ⎤ ⎥ ⎥ ⎦

  Here, L*Q is the same as P*A.
- Input:
  L,Q,P:=LQ([[24,18],[30,24]])
  Output:

  ⎡ ⎢ ⎣ |
  ⎛ ⎜ ⎝ |
  −30.0 | 0.0
  −38.4 | −1.2
  | ⎞ ⎟ ⎠
  | , |
  ⎛ ⎜ ⎝ |
  −0.8 | −0.6
  0.6 | −0.8
  | ⎞ ⎟ ⎠
  | , | ⎡ ⎢ ⎣ |
  1 | 0
  0 | 1
  | ⎤ ⎥ ⎦ | ⎤ ⎥ ⎦

  Again, L*Q = P*A.