Say I have a function $f(x,y)$ with $x$ and $y$ in some domains. How do I find the subdomain in $y$ for which $f$ does not depend on $x$.

My special case one could consider as an example:

I have a Spherical Harmonics $Y_{l,m}(\theta,\phi)$. I want to find constraints on $l,m,\theta$ that would imply a non-dependence upon $\phi$. I know this independence because of physical reasons Mathematica could not infer.

How can I tell Mathematica something like:

$\qquad \mathsf{Solve}[Y_{l,m}(\theta,\phi)==Y_{l,m}(\theta,\phi^\prime)\ \forall\phi,\phi^\prime\in[0,2\pi]]$

I know the answer in this case:

$\qquad Y_{l,m}(\theta,\phi)=Y_{l,m}(\theta,\phi^\prime)\ \forall\phi,\phi^\prime\in[0,2\pi] \rightarrow m=0$

Note: Mathematica knows SphericalHarmonicY[l, m, theta, phi].

In reference to a comment by @patrick-stevens: one could differentiate the function. Nevertheless, it is not the case in general and I am looking for other methods.

  • 2
    $\begingroup$ You could just differentiate with respect to x, and find intervals where that is zero. $\endgroup$ Sep 25, 2015 at 17:07
  • $\begingroup$ you can find some more solutions like this: FindInstance[ SphericalHarmonicY[l, m, theta, RandomReal[]] == SphericalHarmonicY[l, m, theta, RandomReal[]], {l, m, theta}, Integers, 10] $\endgroup$
    – george2079
    Sep 25, 2015 at 17:56

1 Answer 1


In general it would boil down to doing something like:

f[x_, y_] := Sin[y] x

Resolve[ForAll[x, f[x, y] == f[0, y]], Reals]
(* Sin[y] == 0 *)


f[x_, y_] := 2 + 9 x - 6 x y + x y^2

Resolve[ForAll[x, f[x, y] == f[0, y]], Reals]
(* -3 + y == 0 *)

However, quite often this will lead to systems that Mathematica can't solve, like your case

g[l_, m_, θ_, ϕ_] := SphericalHarmonicY[l, m, θ, ϕ]

Resolve[ForAll[ϕ, 0 <= ϕ <= 2 π, g[l, m, θ, ϕ] == g[l, m, θ, 0]]]

Mathematica graphics

although FindInstance can find one special case:

FindInstance[Resolve[ForAll[ϕ, 0 <= ϕ <= 2 π, g[l, m, θ, ϕ] == g[l, m, θ, 0]]], 
    {l, m, θ}]
(* {{l -> 0, m -> 0, θ -> 0}} *)

Your Answer

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

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