0

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`Private`operator[
   DifferentialOperator[]], θ][f[θ]])];
f[θ_] := Cos[θ] Subscript[
    DifferentialOperator`Private`operator[DifferentialOperator[]], r]
oper[f, θ]

Link of the Package that I am using

PacletInstall["https://github.com/carlwoll/DifferentialOperator/releases/download/0.1/DifferentialOperator-0.0.1.paclet"]
xzczd
  • 65,995
  • 9
  • 163
  • 468
Ibrahim
  • 37
  • 4
  • 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: https://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. – xzczd Jul 10 '21 at 16:46

1 Answers1

2

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[θ]^2Derivative[1, 0][f][r, θ])/r - (Cos[θ]Sin[θ]*Derivative[1, 1][f][r, θ])/r

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
  • This approach might not always work as expected. In general one must account for lack of commutativity when working with differential operators. – Daniel Lichtblau Jul 11 '21 at 16:02