I have a very basic question. I am trying to code the LHS of the differential equation: $$\Big[\frac{1}{\sin\theta}\frac{d}{d\theta}\big(\sin\theta\frac{d}{d\theta}\big)-\frac{m^2}{\sin^2\theta}+n(n+1)\Big]f(\theta)=0$$ into Mathematica. As you can see, in the first term, the differential operator is nested and is to properly act on the function $f(\theta)$.
I tried to use #1
, but (lol) I don't know how to use it!
This is what I have:
Sin[θ]^(-1) D[Sin[θ] D[#1, θ], θ] - m^2*#1/Sin[θ]^2 + n (n + 1) #1
What next?!
Also: I don't want to just stick in f[θ]
into where I have #1
, because eventually I would like to be able to make change of variables!
Answer
Why not just define a Function
?
ClearAll[m, n, x, foo]
oper = Function[{f, \[Theta]}, (1/
Sin[\[Theta]] D[Sin[\[Theta]] D[f[\[Theta]], \[Theta]]] -
m^2/Sin[\[Theta]]^2 f[\[Theta]] + n (n + 1) f[\[Theta]])];
oper[foo, x]
foo[x_] := Sin[x]*Cos[x]*x^4
oper[foo, x]
Comments
Post a Comment