I'm trying to rotate a scalar valued function $$f(\theta,\phi)$$ on a sphere. Following this post, I get $$ \begin{pmatrix} f'(\theta',\phi')\sin\theta'\cos\phi'\\ f'(\theta',\phi')\sin\theta'\sin\phi'\\ f'(\theta',\phi')\cos\theta' \end{pmatrix} =R.\begin{pmatrix} f(\theta,\phi)\sin\theta\cos\phi\\ f(\theta,\phi)\sin\theta\sin\phi\\ f(\theta,\phi)\cos\theta \end{pmatrix}$$

where $$R$$ is the rotation matrix. Is there a way to solve for $$f'(\theta',\phi')$$ using Mathematica? I tried using Solve but it returned the error "This system cannot be solved with the methods available to Solve". Any help would be appreciated. TIA!

  • $\begingroup$ fp[θ_, φ_] := f @@ Rest[ToSphericalCoordinates[R . FromSphericalCoordinates[{1, θ, φ}]]] could work if I understand your question correctly. $\endgroup$
    – Roman
    Oct 15, 2021 at 15:35
  • $\begingroup$ @Roman Hm, for some reason, this is giving me zero everywhere. I tried f[theta_, phi_]:=Exp[-theta^2]Cos[phi] and R={{0, 0, 1}, {0, 1, 0}, {-1, 0, 0}}. $\endgroup$ Oct 15, 2021 at 17:48

1 Answer 1


Let f be your function that you wish to rotate


The rotations are best parametrized by the Euler angles



Now we manipulate the plot


Corresponding rotation formulas can be found in p. 23 (Eqs. 2, 3) of Varshalovich Quantum Theory of Angular Momentum (World Scientific Pub. 1988). The book is in free access from the publisher. For convenience I retype the formulas here:

Direct transform:

$$\cos\theta'=\sin(\beta) \sin(\theta) \cos(\phi -\alpha)+\cos(\beta) \cos(\theta),\\ \cot(\phi'+\alpha)=\frac{\cos(\beta ) \cos(\phi -\alpha)-\sin(\beta) \cot(\theta)}{\sin(\phi -\alpha)}. $$

Inverse transform: $$\cos\theta=\cos(\beta) \cos(\theta')-\sin(\beta) \sin(\theta' ) \cos(\gamma +\phi'),\\ \cot(\phi-\alpha)=\frac{\cos(\beta ) \cos(\gamma +\phi' )+\sin(\beta) \cot(\theta')}{\sin(\gamma +\phi')}. $$ In these equations

  • $0\le\theta<\pi,0\le\phi<2\pi$ are the initial spherical coordinates (angles),
  • $0\le\theta'<\pi,0\le\phi'<2\pi$ are the transformed (rotated) angles,
  • $0\le\alpha<2\pi, 0\le\beta<\pi, 0\le\gamma<2\pi$ are the Euler angles ($z$-$y$-$z$).

Finally, in the case when a rotation matrix is given instead of the Euler angles, they can be found using the EulerAnglescommand.

  • $\begingroup$ @123infinity does my post answer your question? $\endgroup$
    – yarchik
    Oct 18, 2021 at 9:22
  • $\begingroup$ Thank you for the detailed answer. But this doesn't give me f', does it? I was hoping to get f'(theta',phi') and substitute the values of theta' and phi' to find the rotated function. $\endgroup$ Oct 18, 2021 at 13:56
  • $\begingroup$ @123infinity $f'(\theta',\phi')=f(\theta,\phi)=f(\theta(\theta',\phi'), \phi(\theta',\phi'))$, as exactly written in my post. $\endgroup$
    – yarchik
    Oct 18, 2021 at 18:40
  • 1
    $\begingroup$ Okay,that makes sense. Thanks! $\endgroup$ Oct 19, 2021 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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