1
$\begingroup$

Could someone help me understand why this code does not work?

enter image description here

I paste the code here but I am unable to format it:

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

($Failed)

PacletUninstall

(PacletUninstall)

PacletInstall[ForceVersionInstall -> True]

(PacletInstall[ForceVersionInstall -> True])

    ( {
   {Subscript[\[PartialD], x], 0},
   {0, Subscript[\[PartialD], x]}
  } ) . ( {
   {x^2},
   {E^ax}
  } )

I have tried the following:

enter image description here

But this does not apply the operators to the right hand side matrix

$\endgroup$
4
  • $\begingroup$ Have you tried to follow the first warning and re-install the package, and then Get that package? $\endgroup$
    – Lacia
    Dec 1, 2022 at 0:45
  • $\begingroup$ Yes, I have run PacletUninstall as well as PacletInstall[ForceVersionInstall -> True] and still doesn't work $\endgroup$
    – NC520
    Dec 1, 2022 at 0:50
  • 1
    $\begingroup$ I'm not familiar with his package, but with Subscript[\[PartialD], x] replaced by DifferentialOperator[x], I get {{x^2 Subscript[\[PartialD], x]},{E^ax Subscript[\[PartialD], x]}}. Is this what you expect? $\endgroup$
    – Lacia
    Dec 1, 2022 at 1:13
  • $\begingroup$ Helpful, but not quite what I need. I would need the operator to be applied to the elements of the second matrix. I will update the question accordingly $\endgroup$
    – NC520
    Dec 1, 2022 at 1:20

1 Answer 1

1
$\begingroup$

If you read the corresponding examples for the package shown in this post carefully, you'll notice the operator created by the package and the expression to be differentiated isn't linked by Times, but Construct i.e. code like

L = DifferentialOperator[x];
L@Exp[a x]

will work, but

L = DifferentialOperator[x];
L Exp[a x]

won't. This design is reasonable, because Times is commutative, but differential operator is not. Dot (.) evaluates to combination of Times and Plus so DifferentialOperator won't work in it, either.

To fix the code, we can use Inner as shown in this and this post:

Inner[If[FreeQ[#1, DifferentialOperator], Times[##], Construct[##]] &,
      {{DifferentialOperator[x], 0}, 
       {0, DifferentialOperator[x]}}, 
      {x^2, Exp[a x]}]

(* {2 x, a E^(a x)} *)
$\endgroup$
3
  • $\begingroup$ Thank you. I think I am totally confused though. I still don't obtain your result. My output is {DifferentialOperator[x][x^2], DifferentialOperator[x][E^(a x)]} $\endgroup$
    – NC520
    Dec 1, 2022 at 9:46
  • 1
    $\begingroup$ @nc520 Sounds like you haven't loaded the package. Have you executed <<DifferentialOperator`? $\endgroup$
    – xzczd
    Dec 1, 2022 at 10:07
  • $\begingroup$ Thanks it worked. Excellent answer $\endgroup$
    – NC520
    Dec 1, 2022 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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