Message Boards Message Boards

1
|
627 Views
|
3 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Matrix multiplication between an operator Matrix and another

Posted 2 months ago

Hi guys,

Happy new Year!

Can you please help with this kind of multiplication of Matrices in Mathematica?

I have a Matrix A [operator matrix, Dimensions 6x3]=> enter image description here which I need to "multiply" with a Matrix B [Dimensions 3xn] that contains expressions of x,y,z in its various elements, in a way that when they are multiplied I will get a 6xn matrix of the derivatives of the corresponding elements of Matrix B.

I have tried using the Map function with no luck.

Thanks!

POSTED BY: Thanos Theodorou
3 Replies

So it sounds like B is a 3xn matrix, where each column {xj,yj,zj} is the components of some separable function fj[x,y,z] = xj + yj + zj?

I'm going to slightly change the definition instead and have a length n vector of functions of x,y,z {f1[x,y,z], ... , fn[x,y,z]}

I first create a matrix A where a 1 denotes "differentiate with this variable":

vars = {x, y, z};
nVars = Length@vars;

A = With[{id = IdentityMatrix[nVars]},
   id~Join~(id + RotateLeft[id])];
A // MatrixForm

enter image description here

Then calculate the Jacobian and transpose. Here for example with 2 functions:

n = 2;
funs = Table[Symbol["f" <> ToString[i]] @@ vars, {i, n}];
J = Outer[D, funs, vars] // Transpose;
J//MatrixForm

enter image description here

Then dot A with the transposed Jacobian J:

(A . J) // MatrixForm

enter image description here


We can alternatively do this without naming the variables, and just specifying which argument we want to differentiate with using A:

ClearAll["`*"]
nVars = 3;
id = IdentityMatrix[nVars];

A = id~Join~(id + RotateLeft[id]);

n = 2;
funNames = Symbol["f" <> ToString[#]] & /@ Range[n];
J = Outer[Derivative[Sequence @@ #1][#2] &, id, funNames, 1, 1];

A . J // MatrixForm

enter image description here

There is likely a much cleaner way to do this using Inner, but I haven't figured out a nice way of doing it yet.

POSTED BY: David Trimas

Also, do please let me know if I'm misunderstanding your definition of B, because I have a feeling that I might be interpreting it incorrectly.

POSTED BY: David Trimas

Hi David,

Thank you very much for your answer!

Matrix b is something like that => enter image description here

I will look into the answer you gave me and let you know if this works for me. Thanks!

POSTED BY: Thanos Theodorou
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