3
$\begingroup$

i'm new in MATHEMATICA. I want to create an operator $D^{(f)}=\partial_x+f'-\partial^2_x$ and $D^{(g)}=\partial_x+g'-\partial^2_x$ and put it into a matrix element, then multiplied by a vector whose components are functions on $x$, say $u(x), v(x)$. For example $$\begin{pmatrix}D^{(f)} & D^{(g)}\\ D^{(g)} & D^{(f)} \end{pmatrix} \begin{pmatrix} u(x) \\ v(x) \end{pmatrix}$$

I saw the posts: Computing with matrix differential operators, How to do matrix operation if the first matrix is an operator?; but i'm very newbie on this.

My problem lives on the fact that I have problems with the matrices products because I have operators

Thanks!

EDIT: $f=f(x,y,z)$ and $g=g(x,y,z)$, both of them are function of a vector $(x,y,z)$, but we can neglect the components $y,z$ and consider only the $x$ part

$\endgroup$
  • $\begingroup$ Here, f and g are some functions on x or not? What are they? $\endgroup$ – Kiro Jun 1 '17 at 8:25
  • $\begingroup$ If you write df = (D[#, {x, 1}] + (-D[#, {x, 2}]) &);, dg = (D[#, {x, 1}] + (-D[#, {x, 2}]) &);, mat = {{df, dg}, {dg, df}} , vec = {u[x], v[x]}, then CenterDot[mat, vec] works, with CenterDot given in the former of the linked questions. This is without f and g but adding them should be very straightforward. $\endgroup$ – Kiro Jun 1 '17 at 8:57
  • $\begingroup$ For v11.3, Construct can be used, e.g., Inner[Construct, {{a # &, \!\( \*SubscriptBox[\(\[PartialD]\), \(x\)]#\) &}, {\!\( \*SubscriptBox[\(\[PartialD]\), \(y\)]#\) &, d # &}}, {u[x, y], v[x, y]}]. $\endgroup$ – Αλέξανδρος Ζεγγ Jul 1 '18 at 8:06
2
$\begingroup$

We can start by defining our two differential operators and putting them into a matrix, like this:

ClearAll["Global`*"]

df[w_] := D[w, x] + f'[x] w - D[w, x, x]
dg[w_] := D[w, x] + g'[x] w - D[w, x, x]
m = {{df, dg}, {dg, df}};

Now we need a way for the matrix operator to act on the vector. This is not plain multiplication. One way to get the matrix operator to act on a vector is to define a function to do it, like this:

operate[matrix_, column_] := 
 Table[Inner[#1[#2] &, μ, column, Plus], {μ, matrix}]

The above function is basically what those other posts were saying. Now we can use the function to apply the matrix operator to our vector.

result = operate[m, {u[x], v[x]}];
result // MatrixForm

(*
  {u[x] f'[x] + v[x] g'[x] + u'[x] + v'[x] - u''[x] - v''[x], 
   v[x] f'[x] + u[x] g'[x] + u'[x] + v'[x] - u''[x] - v''[x]}  *)

We could have defined our functions f[x] and g[x] at any point. For example, we can do it now, as

f[x] := Sin[x]
result
(*
  {Cos[x] u[x] + v[x] g'[x] + u'[x] + v'[x] - u''[x] - v''[x], 
   Cos[x] v[x] + u[x] g'[x] + u'[x] + v'[x] - u''[x] - v''[x]}
*)
$\endgroup$
  • 1
    $\begingroup$ Simpler is operate[matrix_, column_] := Inner[Compose, matrix, column] although Compose is no longer documented. $\endgroup$ – Carl Woll Jun 1 '17 at 15:08
2
$\begingroup$

You can make use of my DifferentialOperator paclet to do this. Install with:

PacletInstall["https://github.com/carlwoll/DifferentialOperator/releases/download/0.1/DifferentialOperator-0.0.2.paclet"]

and load with:

<<DifferentialOperator`

Here is an animation:

enter image description here

Also, notice how I used two different variations of the second order differential operator.

Here is the final answer so that it can be compared with other answers:

{
u[x] f'[x] + v[x] g'[x] + u'[x] + v'[x] - u''[x] - v''[x], 
v[x] f'[x] + u[x] g'[x] + u'[x] + v'[x] - u''[x] - v''[x]
}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.