I have function : $ \partial_{Ax}(x_{i},\dots,x_{n}) = \Sigma_{i,j} A_{i,j}x_{i}\frac{\partial}{\partial x_{j}}. $

where $\partial Ax$ denotes differentiation the vector $Ax$, where $A$ is endomorphism of ${R^n}$.

For example: $ \partial_{Ax}(x_{1},x_{2}) = A_{1,1}x_{1}\frac{\partial}{\partial x_{1}} + A_{1,2}x_{1}\frac{\partial}{\partial x_{2}} + A_{2,1}x_{2}\frac{\partial}{\partial x_{1}} + A_{2,2}x_{2}\frac{\partial}{\partial x_{2}} $

I try define like that where n=2 and matrixA is random matrix $2x2$

 dAx[Subscript[x, 1] _, Subscript[x, 2] _] := 
    Sum[ matrixA[[i]][[j]] *  Subscript[x, i] * 
    D[Subscript[x, j], {Subscript[x, j], 1}], {i, 1, 2}, {j, 1, 2}];

Substric[x,i] mean $x_i$

Output of dAx[3,0] is same as input. What is incorrect?


closed as unclear what you're asking by glS, gwr, MarcoB, happy fish, Öskå Mar 30 '17 at 19:36

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


Both your description and your code are quite confusing (at least to me). For example, I don't understand what "$End(R^n)$" signifies, so I chose to just ignore that and treat A as an arbitrary matrix. I also wasn't certain whether you want a vector or a scalar operator. Anyway, I think what you're asking for can be expressed as something close to the following:

f[A_?MatrixQ, x_?VectorQ] /; Equal @@ Dimensions[A] && Length[x] == Length[A] :=
 Block[{Function, D},
    A[[ii, jj]] x[[ii]] D[#, x[[jj]]],
    {jj, Last@Dimensions[A]},
    {ii, First@Dimensions[A]}
   ] &

For example, it gives:

ff = f[Array[A, {2, 2}], Array[x, 2]]
(* -> A[1, 1]*D[#1, x[1]]*x[1] + A[1, 2]*D[#1, x[2]]*x[1] +
      A[2, 1]*D[#1, x[1]]*x[2] + A[2, 2]*D[#1, x[2]]*x[2] & *)

which is a function that operates on some expression that is a function of the elements of the vector x, such as

ff[x[1] Log[x[2]]]
(* -> A[2, 2]*x[1] +          A[1, 1]*Log[x[2]]*x[1] +
      (A[1, 2]*x[1]^2)/x[2] + A[2, 1]*Log[x[2]]*x[2]   *)

Maybe it's what you wanted; maybe not. If not, please clarify your question.

  • $\begingroup$ What is the purpose of specifying {Function, D} as Block first argument (instead of Block[{})? $\endgroup$ – anderstood Mar 26 '17 at 13:37
  • 1
    $\begingroup$ @anderstood because we do not want Function or D to have their usual meanings while we construct this operator. Try it without and see what the result will be. Block with an empty localization list would be useless. $\endgroup$ – Oleksandr R. Mar 26 '17 at 13:40
  • $\begingroup$ @OleksandrR. Thanks. It's what I wanted. :) $\endgroup$ – user47089 Mar 26 '17 at 13:54