# How to differentiate a composite function which includes unknown functions?

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?

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

Φ[r_, θ_, ϕ_] := {r Sin[θ] Cos[ϕ], r Sin[θ] Sin[ϕ], r Cos[θ]}

$$\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\}$$