2
$\begingroup$

Let $f$ be a $C^2$ function from $\mathbb{R}^3$ to $\mathbb{R}$.
Let $\Phi$ be the function from $(0, \infty) \times [0, \pi] \times [0, 2 \pi]$ to $\mathbb{R}^3$ such that $\Phi(r, \theta, \phi) = (r \sin \theta \cos \phi, r \sin \theta \sin \phi, r \cos \theta)$.

I want to compute $\frac{\partial f \circ\Phi}{\partial r}$, $\frac{\partial f \circ\Phi}{\partial \theta}$, $\frac{\partial f \circ\Phi}{\partial \phi}$.

How to compute this?

$\endgroup$
4
  • 1
    $\begingroup$ Grad[f@\[CapitalPhi][r, \[Theta], \[Phi]], {r, \[Theta], \[Phi]}]? $\endgroup$
    – kglr
    Feb 28, 2020 at 8:52
  • $\begingroup$ @kglr Thank you very much. It worked for me. $\endgroup$
    – tchappy ha
    Feb 28, 2020 at 9:00
  • $\begingroup$ tchappy, posted the comment as an answer. $\endgroup$
    – kglr
    Feb 28, 2020 at 9:17
  • $\begingroup$ @kglr Thank you again! $\endgroup$
    – tchappy ha
    Feb 28, 2020 at 9:20

1 Answer 1

3
$\begingroup$
Φ[r_, θ_, ϕ_] := {r Sin[θ] Cos[ϕ], r Sin[θ] Sin[ϕ], r Cos[θ]}

grad = Grad[f@Φ[r, θ, ϕ], {r, θ, ϕ}] 

TeXForm @ Style[grad, TextAlignment -> Left] 

$\scriptsize\left\{\cos (\theta ) f^{(\{0,0,1\})}(\{r \sin (\theta ) \cos (\phi ),r \sin (\theta ) \sin (\phi ),r \cos (\theta )\})+\\ \ \ \ \sin (\theta ) \sin (\phi ) f^{(\{0,1,0\})}(\{r \sin (\theta ) \cos (\phi ),r \sin (\theta ) \sin (\phi ),r \cos (\theta )\})+\\ \ \ \ \sin (\theta ) \cos (\phi ) f^{(\{1,0,0\})}(\{r \sin (\theta ) \cos (\phi ),r \sin (\theta ) \sin (\phi ),r \cos (\theta )\}),\\ -r \sin (\theta ) f^{(\{0,0,1\})}(\{r \sin (\theta ) \cos (\phi ),r \sin (\theta ) \sin (\phi ),r \cos (\theta )\})+\\ \ \ \ r \cos (\theta ) \sin (\phi ) f^{(\{0,1,0\})}(\{r \sin (\theta ) \cos (\phi ),r \sin (\theta ) \sin (\phi ),r \cos (\theta )\})+\\ \ \ \ r \cos (\theta ) \cos (\phi ) f^{(\{1,0,0\})}(\{r \sin (\theta ) \cos (\phi ),r \sin (\theta ) \sin (\phi ),r \cos (\theta )\}),\\r \sin (\theta ) \cos (\phi ) f^{(\{0,1,0\})}(\{r \sin (\theta ) \cos (\phi ),r \sin (\theta ) \sin (\phi ),r \cos (\theta )\})-\\ \ \ \ r \sin (\theta ) \sin (\phi ) f^{(\{1,0,0\})}(\{r \sin (\theta ) \cos (\phi ),r \sin (\theta ) \sin (\phi ),r \cos (\theta )\})\right\}$

$\endgroup$

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.