I have an expression of the form:
$$c {\partial^{k+l} \Phi(\theta,\phi,n) \over \partial \theta^k \partial \phi^l}$$
$n,k,l$ are (positive) integers. $c$ is some constant. It is also possible that $c$ appears by itself. I would like a function, myExprToList
that takes such an expression as input and outputs in an array: {c,k,l,n}
, or just {c}
if the constant is by itself.
As an example, suppose I have the two expressions:
expr1 = 42 D[D[\[CapitalPhi][\[Theta], \[Phi], 10], {\[Theta], 2}], {\[Phi], 3}]
expr2 = -1
I would then want respectively:
myExprToList[expr1] (* Out: {42,2,3,10} *)
myExprToList[expr2] (* Out: {-1} *)
My first instinct was to use the function PolynomialRemainder
, but since the $k,l,n$ are a prior unknown, I would need to use patterns and I am not sure how this would work.