Inconsistent results between hand calculation and D function of a matrix

I calculate the derivative of a matrix by hand,then use the D instruction of MMA to verify the manual calculation results, but the results are not consistent. Why is this?

The manual calculation method is as follows:

The code is as follows. For the convenience of observation, the parameters here are given numerical values.

{a = 1, b = 2, c = 3, d = 4};
S = {{a, b}, {c, d}};
a1 = D[MatrixPower[S, t/dt], t];
a2 = MatrixPower[S, t/dt] . Log[S]/dt;
a1 /. {t -> 0.1, dt -> 0.1}
a2 /. {t -> 0.1, dt -> 0.1}

Try MatrixLog[S] instead of Log[S].

Yes, I found the problem, thank you! But it seems that MatrixLog can only calculate square matrix. What if the matrix is non square matrix?

Just like the following example:

{a = 1, b = 2};
S = {a, b};
MatrixLog[S]

MatrixLog, just like MatrixPower, and all analytic functions of matrices, is only for square matrices: Wikipedia

I see. Where can I find the calculation method for MatrixLog? And I want to try using Log to replicate the solution of MatrixLog because my formula contains non square matrice.

The documentation on MatrixLog has some hints on the algorithm. As for the logarithm of a nonsquare matrix, it makes no sense at all. Your original problem was the derivative of a MatrixPower. What is the meaning of MatrixPower[A,2], for example? It is the matrix multiplication A.A. How can you calculate A.A if A is not square?

Log[A] is simply the entry-wise Log of the entries.

I want to transform the formula into the relationship between t and dt (i.e. the left side is the variable t, and the right side is the formula containing all variables dt), so I have manually derived the following:

The code is as follows:

{r = 22, l = 2 10^-1, c = 1 10^-4, vi = 24};
\[CapitalDelta]vi = 0;
A = {{0, -1/l}, {1/c, -1/(r c)}};
G = Inverse[A];
B = {1/l, 0};
S1 = Inverse[DiagonalMatrix[{1, 1}] - dt*A + 1/2*dt*dt*A . A];
S2 = Inverse[DiagonalMatrix[{1, 1}] - dt*A];
STAR1 = S1 . G . (B*vi + G . B*\[CapitalDelta]vi/dt) - 
   G . (B*(vi + \[CapitalDelta]vi) + G . B*\[CapitalDelta]vi/dt);
STAR2 = S2 . G . (B*vi + G . B*\[CapitalDelta]vi/dt) - 
   G . (B*(vi + \[CapitalDelta]vi) + G . B*\[CapitalDelta]vi/dt);
X0 = {0, 0};
t = MatrixLog[(MatrixLog[S2] . X0/dt - 
        Inverse[DiagonalMatrix[{1, 1}] - S2] . STAR2 . MatrixLog[S2]/
         dt) . (MatrixLog[S1] . X0/dt - 
        Inverse[DiagonalMatrix[{1, 1}] - S1] . STAR1 . MatrixLog[S1]/
         dt)] . Inverse[MatrixLog[S1 . Inverse[S2]]]*dt;
t /. dt -> 0.00006

Obviously, the formula contains X0, which is a vector that prevents MatrixLog from working properly

You are dividing a vector by a vector, equating a matrix with a vector…

But there’s nothing wrong with my manual simplification process, right? Emmm

Suppose that A,B are matrices, x,y are vectors, and that A.x == B.y. If I do not misunderstand, you deduce that A/B == y/x, whatever that means.

Yes, then I shouldn’t have made any derivation errors. But the next step is to use the MatrixLog instruction on both sides of the equation, and there will be a problem.

If x,y are vectors, what is the meaning of x/y?

Yes, the division of vectors doesn’t seem to exist. So how should I simplify next? emmm

I don’t know. Do you really need to simplify further?

I think so, because I need to use the relationship between t and dt in the future. I have an idea, if MatrixLog cannot handle vectors, can I find the relationship between the MatrixLog and the Log in MMA, and then use Log instead of MatrixLog in the formula to handle vectors. But at present, I have not found a document that specifically introduces the calculation process of the MatrixLog command.