# MatrixExp[m, v] not always faster than MatrixExp[m].v

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}

• I can't reproduce that. Try quitting kernel between calculations. I'm getting MatrixExp[s1, v]; // AbsoluteTiming{5.*10^-6, Null} – Feyre Jul 27 '16 at 21:18
• @Feyre Hi, I tried quitting kernels between calculations and got the same results. What version of Mathematica are you using? – user64620 Jul 27 '16 at 21:35
• Curious, now I'm getting slow results too. – Feyre Jul 27 '16 at 21:49
• 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. – Daniel Lichtblau Jul 27 '16 at 23:11
• I get very similar results to what the OP shows running his code on V10.4.1 on OS X 10.10.2. – m_goldberg Jul 28 '16 at 0:20

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. )

• "Krylov" is really only good for large, sparse matrices, and mostly intended for use with the action form of the exponential on a vector. – J. M. will be back soon Jul 28 '16 at 1:28
• @J.M. One wonders then why MatrixExp[s1, v] seemingly defaults to this method on my system? – Mr.Wizard Jul 28 '16 at 1:32
• 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"? – J. M. will be back soon Jul 28 '16 at 1:40
• @J.M. BlockDecomposition is even slower when I tested it. The slowdown is also present for sparse matrix m. – user64620 Jul 28 '16 at 14:28
• @Alexey, can you confirm the OP's observations regarding "BlockDecomposition"? – J. M. will be back soon Aug 1 '16 at 6:48