# Very slow (days...) computation of JordanDecomposition of symbolic matrix

I am aware there may exist a similar topic, but I haven't found anything.

Is there any way to speed up computation of JordanDecomposition for a symbolic 5x5 matrix with about symbolic variables? After a day and half the process is still "Running...".

Other operations like matrix multiplication and finding inverse of a matrix take 1.5 second max.

I tried replacing numbers with floating-point numbers, like 0.99 with 99./100., but it deteriorates matrix multiplication timing from about 0.5 second to 1.4 second. And if I replace also numbers like "1" with "1.", the timing improves to 1.2 second.

Setting "\$MaxPrecision" very low (like 1) or setting the precision with sign "" virtually doesn't impact the time of multiplication.

EDIT: here is the code, I realise it may look amateurish, but I'm new to Mathematica. I substituted many expressions that were repeating to speed the process up. This way I got Jordan decomposition for a bit simpler matrix in few seconds, but not for this one...

Does extreme substitution (using one letter for every element) make any sense?

 {{0. + (aahhh aalll)/aap,
0. + ((-((aabbb aal)/
aab) - ((-1 + gamma) lambda m (-1 +
0. + ((-(((-1 + gamma) gamma lambda m omegapi (-1 + r) aal)/
aab) - ((-1 + gamma) lambda m (-1 + r) (1 + r) aal)/
aab + ((-1 + gamma) lambda m (-1 + r) aad)/(d aab)) aalll)/
aap, 0. + ((0. - (gamma r aad)/(d aab)) aalll)/aap,
0. + ((0. - (1.5 (1 + alfa) aag)/aab) aalll)/
aap}, {0. + (alfa (0. - ((r + c (-1 + gamma) lambda r) aaz)/
aab) aacc)/aap,
0. + ((1 - aakk/aab - aae/(d i aab)) aacc)/aap,
0. + ((-1 - (gamma omegapi (r + c (-1 + gamma) lambda r) aamm)/
aab - ((1 + r) (r + c (-1 + gamma) lambda r) aamm)/aab +
aae/(d i aab)) aacc)/aap,
0. + ((0. - (gamma r aai)/(d i aab)) aacc)/aap,
0. + ((0. + aat/(i aab)) aacc)/aap}, {0., 0.,
0. + ((0. + phip) (0. - 1. (0. + (0. - 1. k) aac)))/aap,
0. + aazz/aap,
0. - aazz/aap}, {0. + (alfa (0. + (omegay aall)/aab) aauu)/aap,
0. + (((aabbb aaf)/
aab + ((-1 + r) (r + c (-1 + gamma) lambda r) aaf)/
aab) aauu)/aap,
0. + ((0. + phip) (0. + 1. (0. + (0. + 1. k) aac)))/
aap + ((-((aabbb aaf)/aab) + aavv/aab - aav/aab) aauu)/aap,
0. + (5. (0. + 1. (0. + (0. + 1. k) aac)))/
aap + ((-1. + (gamma (-1 + r) r aaf)/aab) aauu)/aap,
0. - (5. (0. + 1. (0. + (0. + 1. k) aac)))/
aap + ((0. + aaddd/aab) aauu)/
aap}, {0. + ((0. - phik) (aaeee))/
aap + (alfa aaiii (0. + (omegay aall)/aab))/
aap + (alfa (0. - ((r + c (-1 + gamma) lambda r) aaz)/
aab) aammm)/aap + (aahhh (0. + 1. aakkk))/aap,
0. + (aaiii ((aabbb aaf)/
aab + ((-1 + r) (r + c (-1 + gamma) lambda r) aaf)/aab))/
aap + ((1 - aakk/aab - aae/(d i aab)) aammm)/
aap + ((-((aabbb aal)/
aab) - ((-1 + gamma) lambda m (-1 +
r) aad)/(d aab)) (0. + 1. aakkk))/aap,
0. + (aaiii (-((aabbb aaf)/aab) + aavv/aab - aav/aab))/
aap + ((-1 - (gamma omegapi (r + c (-1 + gamma) lambda r) aamm)/
aab - ((1 + r) (r + c (-1 + gamma) lambda r) aamm)/aab +
aae/(d i aab)) aammm)/
aap + ((0. + phip) (0. -
1. (0. - (0. - 1. k) aao + (0. + 1. k) (aass/aab -
gamma r (aann/(d i aab)) + aatt/(i aab) +
1.5 (-(aaccc/aab) - aapp/(i aab))))))/
aap + ((-(((-1 + gamma) gamma lambda m omegapi (-1 + r) aal)/
aab) - ((-1 + gamma) lambda m (-1 + r) (1 + r) aal)/
aab + ((-1 + gamma) lambda m (-1 + r) aad)/(d aab)) (0. +
1. aakkk))/aap, (1. (aaeee))/
aap + (aaiii (-1. + (gamma (-1 + r) r aaf)/aab))/
aap + ((0. - (gamma r aai)/(d i aab)) aajjj)/
aap + (5. (0. -
1. (0. - (0. - 1. k) aao + (0. + 1. k) (aass/aab -
gamma r (aann/(d i aab)) + aatt/(i aab) +
1.5 (-(aaccc/aab) - aapp/(i aab))))))/
aap + ((0. - (gamma r aad)/(d aab)) (0. + 1. aakkk))/aap,
0. + ((0. + aaddd/aab) aaiii)/aap + ((0. + aat/(i aab)) aammm)/
aap - (5. (0. -
1. (0. - (0. - 1. k) aao + (0. + 1. k) (aass/aab -
gamma r (aann/(d i aab)) + aatt/(i aab) +
1.5 (-(aaccc/aab) - aapp/(i aab))))))/
aap + ((0. - (1.5 (1 + alfa) aag)/aab) (0. + 1. aakkk))/aap}}
aaaaa = (-(-1 + gamma) lambda m (-1 + r)^2 + (1 - r) (r +
c (-1 + gamma) lambda r))
aab = (-1.5 (-(-1 + gamma) lambda m (-1 + r)^2 + (1 - r) (r +
c (-1 + gamma) lambda r) + (1 + alfa) aaaaa) -
h lambda aaaaa w - gamma (r + c (-1 + gamma) lambda r) aaf)
aab = (-1.5 (-(-1 + gamma) lambda m (-1 + r)^2 + (1 - r) (r +
c (-1 + gamma) lambda r) + (1 + alfa) aaaaaa) -
h lambda aaaaaa w -
gamma (r + c (-1 + gamma) lambda r) (-3. omegatau -
1.5 alfa omegatau - h lambda omegatau w))
aac = (0. +
0.99 q - (1.4849999999999999 (1 +
alfa) q ((-1 + gamma) lambda m (-1 + r)^2 - (1 - r) (r +
c (-1 + gamma) lambda r) -
omegatau (-gamma r + c gamma lambda r - c gamma^2 lambda r)))/
aab - (0.037125000000000005 (1 + alfa) phik (-aaaaaa y +
gamma (-c lambda m omegay + c gamma lambda m omegay +
c lambda m omegay r - c gamma lambda m omegay r +
omegatau r y - c lambda omegatau r y +
c gamma lambda omegatau r y)))/(i aab))
aad = (3. c d + 1.5 alfa c d - 3. c d gamma omegatau -
1.5 alfa c d gamma omegatau - 3. c d r - 1.5 alfa c d r +
c d h lambda w - c d gamma h lambda omegatau w - c d h lambda r w)
aae = ((-1 + gamma) lambda m (-1 + r) aai)
aaf = (-3. omegatau - 1.5 alfa omegatau - h lambda omegatau w)
aag = (-aaaaa y +
gamma (-c lambda m omegay + c gamma lambda m omegay +
c lambda m omegay r - c gamma lambda m omegay r + omegatau r y -
c lambda omegatau r y + c gamma lambda omegatau r y))
aah = (-gamma r + c gamma lambda r - c gamma^2 lambda r)
aai = (-3. d i - 1.5 alfa d i + 3. d i r + 1.5 alfa d i r -
d h i lambda w + d h i lambda r w)

aaj = (0.99 q (1.5 aaaaa + h lambda aaaaa w +
gamma omegatau (r + c (-1 + gamma) lambda r) (-1.5 -
h lambda w)))
aak = (0.02475 (-1 + gamma) lambda m phik (-1 + r) aal)
aal = (3. c + 1.5 alfa c + c h lambda w)
aam = ((-1 + gamma) lambda m (-1 + r)^2 - (1 - r) (r +
c (-1 + gamma) lambda r) - omegatau aah)
aan = (-(-1 + gamma) lambda m omegay (-1 + r) (1.5 c +
c h lambda w) -
omegatau (r + c (-1 + gamma) lambda r) (-1.5 y - h lambda w y))
aao = (0. + (1 + r) (0. - aak/(i aab)) -
omegapi (0. + (0.02475 (-1 + gamma) gamma lambda m phik (-1 +
r) aal)/(i aab)) + (-1 + gamma) lambda m (-1 +
r) (0. + (0.02475 phik aad)/(d i aab)))
aap = (0. - 1. (0. + (0. + 0.99 phip) (0. + (0. - 1. k) aac)))
aar = (i aab) + (0.03675375 alfa c gamma k phik phip r^2)
aas = aab - (0.02475 phik (1.5 aaaaaa y + h lambda aaaaaa w y -
gamma aan))
aat = (1.5 (1 + alfa) (gamma i omegay r - c gamma i lambda omegay r +
c gamma^2 i lambda omegay r))
aau = 0. - (1.5 aaaaaa y + h lambda aaaaaa w y - gamma aan)
aav = (omegapi (1.5 (-(-1 + gamma) lambda m (-1 + r)^2 + (1 - r) (r +
c (-1 + gamma) lambda r) + (1 + alfa) aaaaaa) +
h lambda aaaaaa w))
aaz = (1.5 gamma omegay + gamma h lambda omegay w)
1.485 = 1.4849999999999999
0.037125 = 0.037125000000000005
aabb = (0. + (0. + 0.99 phip) (0. - 1. aac))
aacc = (0. - (0. + 0.99 phip) (0. + (0. - 1. k) aac))
aadd = (0.0245025 c gamma h k lambda phik phip r w)
aaee = (0.0245025 c gamma^2 h k lambda omegatau phik phip r w)
aaff = (0.03675375 alfa c gamma k phik phip r)
aagg = (0.03675375 alfa c gamma^2 k omegatau phik phip r)
aahh = (0.0735075 c gamma k phik phip r)
aaii = (0.0735075 c gamma^2 k omegatau phik phip r)
aajj = (0.0245025 c gamma h k lambda phik phip r^2 w)
aakk = ((-1 + r) (r + c (-1 + gamma) lambda r) aamm)
aall = (-1.5 aaaaaa - h lambda aaaaaa w)
aamm = (3. + 1.5 alfa + h lambda w)
aann = 0. + (0.02475 phik aad)
aaoo = (i aab) + (0.0735075 c gamma k phik phip r^2)
aapp = (0.02475 (1 + alfa) phik aag)
aarr = 0. + 0.98507475 phik - 0.99 q
aass = 1. - 0.99 q + (1.485 (1 + alfa) q aam)
aatt = (0.037125 (1 + alfa) phik aag)
aauu = (0. + 1. (0. - (0. + 0.99 phip) (0. + (0. + k) aac)))
aavv = ((1 + r) (r + c (-1 + gamma) lambda r) aaf)
aazz = (5. (0. - 1. (0. + (0. - 1. k) aac)))
aabbb = (-1 + gamma) lambda m (-1 + r)^2
aaccc = (0.99 (1 + alfa) q aam)
aaddd = (1.5 (1 + alfa) omegay aaaaaa)
aaeee = 0. + 0.99 k phip
aafff = (0. + 0.99 phip)
aaggg = aaeee - 0.9801 k phip q
aahhh = (0.975 k + alfa (aau/aab))
aaiii = (aaggg - aahh/(i aab) - aaff/(i aab) + aaii/(i aab) +
aagg/aaoo/aar/(i aab) - aadd/(i aab) + aaee/(i aab) + aajj/(i aab))
aajjj = (0. -
aafff (0. - (0. -
1. k) (0. + (-1 + r) (0. - aak/(i aab)) - (-1 +
gamma) lambda m (-1 + r) ( aann/(d i aab)))))
aakkk = (0. - aafff (0. + 1. (aarr + alfa (0. - aaj/aas/(i aab)))))
aalll = (0. - 1. aabb)
aammm = (0. -
aafff (0. - (0. -
1. k) (0. + (-1 + r) (0. - aak/(i aab)) - (-1 +
gamma) lambda m (-1 + r) (aann/(d i aab)))))
`
• Edit: I just realised running identical matrix inverse operation takes anywhere between 0.25 second and 2 seconds. The interval seems rather wide so what I've written regarding floating-type numbers may not affect the timing.
– Svit
Commented Oct 17, 2020 at 16:42
• The dimension will play a role here. And whether or not it has a full set of eigenvectors. The complexity of computing eigenvectors could be quite high since it very likely involves doing linear algebra over some field of rational functions augmented with symbolic root expressions (from the eigenvalues). Commented Oct 17, 2020 at 18:09
• @SvitValenčič Without testing your matrix we can't say nothing. Commented Oct 17, 2020 at 23:12
• Thanks to Daniel and Alex. I added the code and substitutions if it helps.
– Svit
Commented Oct 18, 2020 at 15:06
• It might help to rationalize all the numbers. But I suspect it will still bog down in eigenvector computations. Commented Oct 19, 2020 at 14:16