I am trying to calculate the Hessenberg decomposition of a symbolic matrix

$$ A= \begin{pmatrix} 0 & -\mathrm ia & 0 & b \cos x \\ \mathrm ia & 0 & \mathrm ic \sin x & 0 \\ 0 & -\mathrm ic \sin x & 0 & -\mathrm ia \\ b \cos x & 0 & \mathrm ia & 0 \end{pmatrix}, $$

where $a,b,c,x$ are symbolic variables. Computing the Hessenberg decomposition for a numerical matrix A can be easily obtained using

{P, T} = HessenbergDecomposition[A];   

How can I obtain P and T for my symbolic matrix A?

  • $\begingroup$ Might consider instead using Eigensystem. $\endgroup$ Mar 5, 2020 at 15:43
  • $\begingroup$ Eigensystem gives eigenvectors (full matrix) and eigenvalues (diagonal matrix) but not the Hessenberg form of my matrix. $\endgroup$
    – Shasa
    Mar 6, 2020 at 7:44
  • $\begingroup$ Right, Eigensystem returns an eigensystem. But it can serve in similar use cases to a Hessenberg decomposition and moreover works for symbolic input. HessenbergDecomposition is strictly numeric. Another alternative might be JordanDecomposition by the way. $\endgroup$ Mar 6, 2020 at 15:16

1 Answer 1


It is not overly difficult to write a simple (but inefficient) method for symbolically performing Hessenberg decomposition, based on repeated similarity transformations with Householder matrices. It is interesting to compare the routine for QR decomposition in this answer with the Hessenberg decomposition function given below:

hesdec[mat_?SquareMatrixQ] := Module[{h = mat, r, n, q, v, v2},
   n = Length[h]; q = IdentityMatrix[n];
   Do[v = PadLeft[h[[k + 1 ;;, k]], n];
      v2 = v - SparseArray[{k + 1 -> Norm[v]}, n];
      r = If[! TrueQ[Norm[v2, ∞] == 0], ReflectionMatrix[v2], IdentityMatrix[n]];
      q = q.r; h = r.h.r, {k, n - 2}];
   {q, h}]

Applied to your matrix,

{qq, hh} = hesdec[{{0, -I a, 0, b Cos[x]}, {I a, 0, I c Sin[x], 0},
                   {0, -I c Sin[x], 0, -I a}, {b Cos[x], 0, I a, 0}}];

one however obtains expressions of horrendous complexity:

LeafCount[hs = Simplify[ComplexExpand[hh, TargetFunctions -> {Re, Im}]]]

LeafCount[qs = Simplify[ComplexExpand[qq, TargetFunctions -> {Re, Im}]]]

What to do with these matrices afterwards is up to you. But you might appreciate a little that writing functions like these so that expression swell is minimized is not trivial.

  • $\begingroup$ This is what I was looking for. Thanks! $\endgroup$
    – Shasa
    Mar 23, 2020 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.