the manual solution

Why the manual solution of this partial derivative operator is not the same as in Mathematica, can someone suggest the code is written right or not ? Here is the code

ClearAll[r, θ, f]
oper = Function[{f, θ}, (Sin[θ]/r Subscript[
   DifferentialOperator[]], θ][f[θ]])];
f[θ_] := Cos[θ] Subscript[
    DifferentialOperator`Private`operator[DifferentialOperator[]], r]
oper[f, θ]

Link of the Package that I am using

  • $\begingroup$ Hello, welcome to Mathematica.SE. Then: 1. Please show us the code text rather than a screenshot, you may want to read this to learn how to copy the code properly: mathematica.meta.stackexchange.com/q/1584/1871 2. Since you're using the package DifferentialOperator, you should add link to the package in your post, not everybody knows that package. $\endgroup$
    – xzczd
    Jul 10, 2021 at 16:46

1 Answer 1


What you have labeled as a function is itself a differential operator. In general, they are to be applied to a function of both r and θ

op1 = Cos[θ]*D[#, r] &;

op2 = -Sin[θ]/r *D[#, θ] &;

op2[op1[f[r, θ]]] // Apart

(* (Sin[θ]^2*Derivative[1, 0][f][r, θ])/r - 
   (Cos[θ]*Sin[θ]*Derivative[1, 1][f][r, θ])/r
  • $\begingroup$ This approach might not always work as expected. In general one must account for lack of commutativity when working with differential operators. $\endgroup$ Jul 11, 2021 at 16:02

Your Answer

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

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