Message Boards Message Boards

0
|
1880 Views
|
14 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Inconsistent results between hand calculation and D function of a matrix

Posted 10 months ago

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: enter image description here

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}
POSTED BY: James James
14 Replies
Posted 10 months ago

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.

POSTED BY: James James

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

POSTED BY: Gianluca Gorni
Posted 10 months ago

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

POSTED BY: James James

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

POSTED BY: Gianluca Gorni
Posted 10 months ago

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.

POSTED BY: James James

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.

POSTED BY: Gianluca Gorni
Posted 10 months ago

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

POSTED BY: James James

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

POSTED BY: Gianluca Gorni
Posted 10 months ago

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: enter image description here 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

POSTED BY: James James

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.

POSTED BY: Gianluca Gorni
Posted 10 months ago

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.

POSTED BY: James James

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

POSTED BY: Gianluca Gorni
Posted 10 months ago

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]
POSTED BY: James James

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

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract