7
$\begingroup$

For non sparse matrix m, is MatrixExp[m, v] supposed to be faster than MatrixExp[m].v? This seems to be true only if m is purely real or imaginary.

Block[{n = 500},
v = RandomComplex[1. + I, n];
s = RandomReal[{-1., 1.}, {n, n}];
s1 = RandomComplex[1. + I, {n, n}];
]

MatrixExp[s].v; // AbsoluteTiming

{0.12628, Null}

MatrixExp[s, v]; // AbsoluteTiming

{0.0379219, Null}

MatrixExp[s1].v; // AbsoluteTiming

{0.365637, Null}

MatrixExp[s1, v]; // AbsoluteTiming

{5.17002, Null}

MatrixExp[s1, v, Method -> "Krylov"]; // AbsoluteTiming

{4.93712, Null}

MatrixExp[s1, v, Method -> "Pade"]; // AbsoluteTiming

{0.416058, Null}

$\endgroup$
7
  • $\begingroup$ I can't reproduce that. Try quitting kernel between calculations. I'm getting MatrixExp[s1, v]; // AbsoluteTiming``{5.*10^-6, Null} $\endgroup$
    – Feyre
    Commented Jul 27, 2016 at 21:18
  • $\begingroup$ @Feyre Hi, I tried quitting kernels between calculations and got the same results. What version of Mathematica are you using? $\endgroup$
    – user64620
    Commented Jul 27, 2016 at 21:35
  • $\begingroup$ Curious, now I'm getting slow results too. $\endgroup$
    – Feyre
    Commented Jul 27, 2016 at 21:49
  • 1
    $\begingroup$ I'm voting to close because I cannot reproduce the issue. If others manage to reproduce this reliably then I'm happy to take back that vote. $\endgroup$ Commented Jul 27, 2016 at 23:11
  • $\begingroup$ I get very similar results to what the OP shows running his code on V10.4.1 on OS X 10.10.2. $\endgroup$
    – m_goldberg
    Commented Jul 28, 2016 at 0:20

1 Answer 1

2
$\begingroup$

Mr.Wizard

Timing results in Mathematica 10.1.0 under Windows 7 x64:

{0.0660777, Null}

{0.0303608, Null}

{0.190943, Null}

{1.46382, Null}

{1.41635, Null}

{0.183233, Null}

So I confirm MatrixExp[s1, v] and MatrixExp[s1, v, Method -> "Krylov"] as being slower on my system.


Alexey Popkov

Timing results with Mathematica 10.4.1 under Windows 7 x64 (CPU with 2 physical cores):

{1.26094, Null}

{0.638639, Null}

{1.26434, Null}

{19.7368, Null}

{18.708, Null}

{1.89468, Null}

Mariusz Iwaniuk

Timing results with Mathematica 10.2.0 under Windows 8.1 x64 (CPU with 2 physical cores):

{1.03687, Null}

{0.128066, Null}

{3.9396, Null}

{21.1016, Null}

{21.0798, Null}

{3.95479, Null}

( Use this Community Wiki to share any other timing results of interest. )

$\endgroup$
7
  • $\begingroup$ "Krylov" is really only good for large, sparse matrices, and mostly intended for use with the action form of the exponential on a vector. $\endgroup$ Commented Jul 28, 2016 at 1:28
  • 1
    $\begingroup$ @J.M. One wonders then why MatrixExp[s1, v] seemingly defaults to this method on my system? $\endgroup$
    – Mr.Wizard
    Commented Jul 28, 2016 at 1:32
  • 1
    $\begingroup$ My point was that it is not fair to "Krylov" to be using a dense matrix as the argument; of course it will then be slow. Have you also tried Method -> "BlockDecomposition"? $\endgroup$ Commented Jul 28, 2016 at 1:40
  • $\begingroup$ @J.M. BlockDecomposition is even slower when I tested it. The slowdown is also present for sparse matrix m. $\endgroup$
    – user64620
    Commented Jul 28, 2016 at 14:28
  • $\begingroup$ @Alexey, can you confirm the OP's observations regarding "BlockDecomposition"? $\endgroup$ Commented Aug 1, 2016 at 6:48

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.