I have a program and I need to take the Dot
product of many matrices, which is quite effectively working for small NStep. But for large(=30000), it is failing and saying. Either I use ParallelTable
or not, problem remains.
$IterationLimit::itlim: Iteration limit of 4096 exceeded.
This is my program,
a = 1;
tI = 0.0001;
dt = 0.0001;
NStep=30000;
T1[t_] = j1 (Cos[t]);
T2[t_] = j2 ;
cond = {j1 -> 0.9, j2 -> 1.};
HSm[t_] = ({{0, -(T1[t] + T2[t] Cos[k])}, {-(T1[t] + T2[t] Cos[k]),0}})//. cond;
HStDig[t_] = MatrixExp[t *DiagonalMatrix[Eigenvalues[HSm[t]]]]
us = ParallelTable[HStDig[tI + j dt], {j, 0, NStep}];
us1 = Apply[Dot, us];
How to go about it? Is there a way to speed up the program?
MatrixExp
of a diagonal matrix just the diagonal matrix made up of the elements of that matrix exponentiated? You might save some time putting that in explicitly rather than usingMatrixExp
. $\endgroup$k
is left as a symbol). This is going to be tough for Mathematica's symbolic processing. I would recommend choosing a value fork
, and then doing the multiplication. Finally, since matrix multiplication of diagonal matrices is the same as element-wise multiplication of the matrices, doTimes@@us
rather thanDot@@us
. If you insist on usingDot
, you can doBlock[{$IterationLimit = 30002}, Dot @@ us]
, but it will take longer than theTimes
method. $\endgroup$k
is supposed to be given value from a list of numbers $\endgroup$