2
$\begingroup$

I have a $2 \times 2$ matrix $A$, where each element is a 12th order polynomial in a parameter $a$.

I need to raise this matrix $A$ to the $-t/T$ power, where $T$ is a known scalar (for this instance, it can be assumed $T=1$) and $t$ is a variable.

I have tried simply

MatrixPower[A, -t/T]

but the program ran for over 40 minutes without finishing. This seems unusually long.

Is there a more efficient way of performing this calculation?

Here is my matrix in input form.

A = {
  {1.60938*10^-24 a^12 - 8.90757*10^-22 a^11 + 4.1103*10^-19 a^10 - 
    1.56167*10^-16 a^9 + 4.77859*10^-14 a^8 - 1.1468*10^-11 a^7 + 
    2.08694*10^-9 a^6 - 2.7542*10^-7 a^5 + 0.0000247781 a^4 - 
    0.00138637 a^3 + 0.0414932 a^2 - 0.493382 a + 0.898765, 
   6.40651*10^-26 a^12 - 3.88845*10^-23 a^11 + 1.96554*10^-20 a^10 - 
    8.25818*10^-18 a^9 + 2.82714*10^-15 a^8 - 7.70067*10^-13 a^7 + 
    1.62035*10^-10 a^6 - 2.53518*10^-8 a^5 + 2.80165*10^-6 a^4 - 
    0.000203325 a^3 + 0.00867045 a^2 - 0.179515 a + 1.19691},
  {-6.40651*10^-26 a^13 + 3.86315*10^-23 a^12 - 1.95024*10^-20 a^11 + 
    8.18108*10^-18 a^10 - 2.79488*10^-15 a^9 + 7.5908*10^-13 a^8 - 
    1.59064*10^-10 a^7 + 2.47333*10^-8 a^6 - 2.70645*10^-6 a^5 + 
    0.000193079 a^4 - 0.00796119 a^3 + 0.152113 a^2 - 0.765055 a - 
    0.160599, 
   1.60938*10^-24 a^12 - 8.90756*10^-22 a^11 + 4.1103*10^-19 a^10 - 
    1.56167*10^-16 a^9 + 4.77859*10^-14 a^8 - 1.1468*10^-11 a^7 + 
    2.08694*10^-9 a^6 - 2.7542*10^-7 a^5 + 0.0000247781 a^4 - 
    0.00138637 a^3 + 0.0414932 a^2 - 0.493382 a + 0.898765}
 };
$\endgroup$
5
  • 1
    $\begingroup$ My system (v. 10.0.0, Mac Pro) gave for variable t the full answer instantly (0.0439 seconds). $\endgroup$ Jan 8, 2015 at 1:00
  • $\begingroup$ Interesting. I have 9.0.1.0 Is there a way I can upload my matrix for you to test? $\endgroup$
    – gKirkland
    Jan 8, 2015 at 1:28
  • $\begingroup$ Post your matrix on some website so I can cut and paste it into my machine and post the URL. (We're reluctant to ftp download code onto corporate machines.) $\endgroup$ Jan 8, 2015 at 1:34
  • $\begingroup$ I get a huge result directly in 0.079500 seconds (v. 10.0.0). If you'd like, I can post it to the answer box. (The first entry of which is the Timing[].) $\endgroup$ Jan 8, 2015 at 1:39
  • $\begingroup$ The scale variation of coefficients is large, the polynomial degree not small, and the precision is limited. I would not trust the result to be accurate on substitution for other than modest values of t/T. $\endgroup$ Jan 8, 2015 at 15:47

1 Answer 1

5
$\begingroup$

It seems to be a performance problem (bug?) in version 9.0.1. Version 7.0.1 is also slow, but perhaps is not capable of this calculation. However, version 8.0.4 can produce the correct result quickly, so there seems to be no good reason why 9.0.1 should take so long. I didn't try 9.0.0.

The interesting thing, is that 9.0.1 has no problem with the purely symbolic input:

analytical = MatrixPower[{{x, y}, {z, w}}, -t/T];

Then, you can just get your answer with:

answer = Block[{x, y, z, w}, {{x, y}, {z, w}} = A; analytical]

I am going to go ahead and tag this question with , because I can't see any valid reason for the observed behavior, which is a performance regression (typically treated as a bug). If anyone can think of a good reason and prove me wrong in this, I would be interested to hear about it.

$\endgroup$
3
  • $\begingroup$ Can you expand on what you mean by this? I don't understand this method. $\endgroup$
    – gKirkland
    Jan 8, 2015 at 17:49
  • $\begingroup$ Never mind, I see what you mean now. It is performing the calculation in terms of a matrix {{x,y},{z,w} then substituting the A element in for x, y, z, w correct? $\endgroup$
    – gKirkland
    Jan 8, 2015 at 18:11
  • $\begingroup$ @gKirkland yes, correct. $\endgroup$ Jan 8, 2015 at 21:07

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.