# Derivative matrix by vector in Mathematica

This is an excerpt from the article https://www.sciencedirect.com/science/article/abs/pii/S0094114X10000418.

How do I write this using vector-matrix operations (TensorProduct or KroneckerProduct or other) in Mathematica?

D[A,{X}] will do it because D already operates on all elements of the matrix and the {X} argument (grad) will differentiate w.r.t each part of X. But you'll need to flatten each row to get the form you want:

n = 2; m = 3;
X = Array[x, n]
A = Array[a[#1, #2] @@ X &, {n, m}];

(Flatten /@ D[A, {X}]) // MatrixForm

• thank you for your answer! I need a formal mathematical description of this operation, is it possible?
– dtn
Jul 16 at 9:18
• Not sure what you mean. If anything the maths you've shown is less formal than Mathematica as it loosely inserts vectors into a matrix becoming a bigger matrix of scalars instead of a NxM matrix of vectors. The flattening is like $\text{vec}(...)$. Jul 16 at 9:23
• @dtn the Tensor product and Kronecker product are not relevant here. Jul 16 at 9:25
• @dtn Only Grad or $\nabla$ as this is applied to every entry in the matrix. Jul 16 at 9:27
• @dtn it's just Flatten /@ D[Q, {v}] ?? Jul 16 at 10:05