1
$\begingroup$

I would like to apply the differential operator

$- (\partial_\theta -\frac{i}{\sin (\theta)} \partial_\phi + s \cot (\theta))$

to a function $F$ (Spherical Harmonics), which is dependent on $\theta$ and $\phi$ like SphericalHarmonicY[l, m, θ, ϕ]. How do I write this differential operator in Mathematica? The implementation should not depend on the particular function.

A non-working attempt I made is

 (-Derivative[0, 0, 1, 0] + I/Sin[θ] Derivative[0, 0, 0, 1] + s Cot[θ]) 
   SphericalHarmonicY[l, m, θ, ϕ]

But Mathematica didn't resolve the derivatives as stated in Derivative. Is there an easy solution to this, that works like multiplication from the left?

This question seems to solve this by repeating f after every differential. Is this really necessary? Mathematically, differential operators should not care about what comes after them, should they?

Edit

Just found this question about writing differential operators, but don't really understand it.

$\endgroup$
3
  • $\begingroup$ You need to write the operator as a pure function and enclose its argument in square brackets: (-Derivative[0, 0, 1, 0][#] + I/Sin[\[Theta]] Derivative[0, 0, 0, 1][#] + s Cot[\[Theta]]) & [ SphericalHarmonicY[l, m, \[Theta], \[Phi]]] $\endgroup$
    – Bob Hanlon
    Commented May 3, 2018 at 15:09
  • $\begingroup$ @BobHanlon it appears that you missed 's Cot[[Theta]] #', which seems to throw a monkey wrench into your solution since it somehow cant evaluate this. (it outputs (0&) at the end of each result). Full line: Y[s_, l_, m_, [Theta]_, [Phi]_] := Simplify[(-1)^ s Sqrt[(l + s)!/(l - s)!] (-Derivative[0, 0, 1, 0][#] + I/Sin[[Theta]] Derivative[0, 0, 0, 1][#] + s Cot[[Theta]] Derivative[0, 0, 0, 0][#]) & [ SphericalHarmonicY[l, m, [Theta], [Phi]]], Assumptions -> {-l <= s <= 0, -[Pi] <= [Phi] <= [Pi], 0 < [Theta] < [Pi]}]; $\endgroup$
    – Gladaed
    Commented May 3, 2018 at 15:35
  • $\begingroup$ I did not understand that the s Cot[\[Theta]] was supposed to be multiplied by the argument. Just change to (-Derivative[0, 0, 1, 0][#] + I/Sin[\[Theta]] Derivative[0, 0, 0, 1][#] + s Cot[\[Theta]] #) &[ SphericalHarmonicY[l, m, \[Theta], \[Phi]]] There is no 0& $\endgroup$
    – Bob Hanlon
    Commented May 3, 2018 at 15:42

2 Answers 2

4
$\begingroup$

You can use my DifferentialOperator package to do what you want. Install with:

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

and load with:

<<DifferentialOperator`

Here's a short animation of the package in action for your question:

enter image description here

For more details, see my answer to the linked question.

$\endgroup$
4
  • $\begingroup$ YOur package seems perfect. Is it compatible with mathematica 11.3? i get a red cell markation if i enter L2 = esc pd esc ctrl+- x enter $\endgroup$
    – Gladaed
    Commented May 4, 2018 at 11:41
  • $\begingroup$ Don’t use esc, just use pd without the escapes $\endgroup$
    – Carl Woll
    Commented May 4, 2018 at 12:30
  • $\begingroup$ Thanks, but now op[s_, [Theta]_, [Phi]_] := -(Subscript[ DifferentialOperatorPrivateoperator[ DifferentialOperator[]], [Theta]] - I/Sin[[Theta]] Subscript[ DifferentialOperatorPrivateoperator[ DifferentialOperator[]], [Phi]] + s Cot[[Theta]]); Y[s_, l_, m_, [Theta]_, [Phi]_] := Simplify[(-1)^ s ((l - s)!/(l + s)!) (op[s, [Theta], [Phi]] @ SphericalHarmonicY[l, m, [Theta], [Phi]]), Assumptions -> {-l <= s <= 0, -[Pi] <= [Phi] <= [Pi], 0 < [Theta] < [Pi]}] $\endgroup$
    – Gladaed
    Commented May 7, 2018 at 9:19
  • $\begingroup$ (* A contains vector vectors of length n *) h[h11_, h22_, [Theta]_, [Phi]_] := h22 * Y[-2, 2, 2, [Theta], [Phi]]; h[A[[All, 2]], A[[All, 3]], 1, 1] does throw an error, which can be avoided if phi and theta are replaced by a rule, which seems laborious. $\endgroup$
    – Gladaed
    Commented May 7, 2018 at 9:19
3
$\begingroup$

You can simply use:

opL[f_]:=-(D[f,θ]-(I/Sin[θ])*D[f,φ]+s*Cot[θ]*f)
$\endgroup$
2
  • $\begingroup$ I prefer a pure function version. $\endgroup$ Commented May 4, 2018 at 6:51
  • $\begingroup$ @Αλέξανδρος Ζεγγ I like this version because when the operator is applied to a function it look very similar the way in which I write it. $\endgroup$
    – vi pa
    Commented May 4, 2018 at 11:15

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