# Performing Hessenberg decomposition on a symbolic matrix

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?

• Might consider instead using Eigensystem. Mar 5 '20 at 15:43
• Eigensystem gives eigenvectors (full matrix) and eigenvalues (diagonal matrix) but not the Hessenberg form of my matrix. Mar 6 '20 at 7:44
• 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. Mar 6 '20 at 15:16

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}]]]
3583

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


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.

• This is what I was looking for. Thanks! Mar 23 '20 at 17:25