Hessenberg matrix reduction: hessenberg SCHUR

### 5.48.12 Hessenberg matrix reduction: hessenberg SCHUR

A Hessenberg matrix is a square matrix where the coefficients below the sub-principal diagonal are all 0s. The hessenberg command finds a Hessenberg matrix equivalent to a given square matrix.

- hessenberg takes one mandatory argument and one optional argument:
  - A, a matrix.
  - n, an integer, either 0, −1, −2 or a prime number greater than 1 (by default n=0).
- hessenberg(A ⟨ n ⟩) returns a list [P,B] with B=P−1AP and:
  - if n=0, B is a Hessenberg matrix.
  - if n=−1, the calculations are approximate and B is upper triangular.
  - if n=−2, the calculations are approximate, P is orthogonal and B has zero sub-subdiagonal elements.

SCHUR(A) is equivalent to hessenberg(A,-1), which is compatible with HP calculators.

#### Examples.

- Input:

  A:=[[3,2,2,2,2],[2,1,2,-1,-1],[2,2,1,-1,1],[2,-1,-1,3,1],[2,-1,1,1,2]];
  [P,B]:=hessenberg(A)

  or:
  [P,B]:= hessenberg(A,0);
  Output:

  ⎡ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ |
  1 | 0 | 0 | 0 | 0
  0 | 1 | 0 | 0 | 0
  0 | 1 | 1 | 0 | 0
  0 | 1 |
  1
  2
  1
  4
  | 1
  0 | 1 | 1 | 1 | 0
  | ⎤ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ | , | ⎡ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ |
  3 | 8 | 5 |
  5
  2
  | 2
  2 | 1 |
  1
  2
  − |
  5
  4
  | −1
  0 | 2 | 1 | 2 | 0
  0 | 0 | 2 |
  3
  2
  | 2
  0 | 0 | 0 |
  13
  8
  7
  2
  | ⎤ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦

  Indeed:
  Input:
  pcar(A)
  and:
  pcar(B)
  both return:
  Output:

  ⎡ ⎣ | 1,−10,13,71,−50,−113 | ⎤ ⎦

  and it is easily verified that B=inv(P)*A*P.
- With A as above: Input:
  B:= hessenberg(A,-1);
  Output (to 2 digits):

  ⎡ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ | ⎡ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ |  |
  0.73 | −0.057 | −0.42 | −0.17 | −0.51
  0.25 | −0.53 | 0.72 | −0.38 | −0.048
  0.35 | −0.44 | −0.3 | 0.19 | 0.74
  0.34 | 0.68 | 0.17 | −0.46 | 0.43
  0.41 | 0.25 | 0.44 | 0.76 | −0.063
  |  | ⎤ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ |  | ,

  | ⎡ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ |  |
  6.7 | 8.7e−15 | −2e−13 | 2.7e−14 | −1.4e−13
  0.0 | 4.6 | 0 | 0 | 0
  0.0 | 0.0 | −1.9 | 0 | 0
  0.0 | 0.0 | 0.0 | 1.7 | 0
  0.0 | 0.0 | 0.0 | −0.0 | −1.2
  |  | ⎤ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ |  | ⎤ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦