I'm trying to derive the gradient vector in spherical polar coordinates: $$\nabla = \left( \frac{\partial}{\partial x}, \frac{\partial}{\partial y},\frac{\partial}{\partial z} \right)$$The method I am trying to use is different from most papers/videos I found and I don't understand why it doesn't work. I am able to get expressions for the cartesian differentials: $dx, dy, dz$. First, I am just trying to find $\frac{\partial}{\partial x}$ in spherical coordinates. I have: $$dx= \cos \theta \sin \phi dr + r \cos \theta \cos \phi d \theta + r \sin \theta \sin \phi d \phi$$ This sounds strange but my first intuition was to say that: $$\frac{\partial}{\partial x} = \frac{ \partial }{ \cos \theta \sin \phi dr + r \cos \theta \cos \phi d \theta + r \sin \theta \sin \phi d \phi} $$ Which doesn't seem to make any sense now :(. If my logic is wrong, could someone explain to me why?

  • 2
    $\begingroup$ In any orthogonal coordinate system $\xi_1,...,\xi_n$ the gradient is $$\nabla=\left(\frac{1}{h_1}\frac{\partial}{\partial \xi_1},...,\frac{1}{h_n}\frac{\partial}{\partial \xi_n}\right)$$ Proving this in general will produce the formula for spherical coordinates instantly. $\endgroup$
    – K.defaoite
    Commented Oct 13, 2020 at 21:08

2 Answers 2


This is a classic example of why treating something like $\frac{dy}{dx}$ as a literal fraction rather than as shorthand notation for a limit is bad. If you want to derive it from the differentials, you should compute the square of the line element $ds^2 .$ Start with $$ds^2 = dx^2 + dy^2 + dz^2$$ in Cartesian coordinates and then show

$$ds^2 = dr^2 + r^2 d\theta^2 + r^2 \sin^2 (\theta) d\varphi^2 \; .$$ The coefficients on the components for the gradient in this spherical coordinate system will be 1 over the square root of the corresponding coefficients of the line element. In other words

$$\nabla f = \begin{bmatrix} \frac{1}{\sqrt{1}}\frac{\partial f}{\partial r} & \frac{1}{\sqrt{r^2}}\frac{\partial f}{\partial \theta} & \frac{1}{\sqrt{r^2\sin^2\theta}}\frac{\partial f}{\partial \varphi} \end{bmatrix} \; .$$ Keep in mind that this gradient has nomalized basis vectors.

For a general coordinate system (which doesn't necessarily have an orthonormal basis), we organize the line element into a symmetric "matrix" with two indices $g_{ij} .$ If the line element contains a term like $f(\mathbf x)dx_kdx_\ell\; \;$ then $g_{k\ell} = f(\mathbf x).\;$ The gradient is then expressed as

$$\nabla f = \sum_i \sum_j \frac{\partial f}{\partial x_i}g^{ij}\mathbf e_j$$ where $\mathbf e_j$ is not necessarily a normalized vector and $g^{ij}$ is the matrix inverse of $g_{ij}$.

  • 1
    $\begingroup$ Another great answer! It is for this precise reason I often advise people to use differential operator notation, e.g the derivative w.r.t $x$ as $\mathrm{D}_x$ instead of the older fraction notation to avoid costly errors. $\endgroup$
    – K.defaoite
    Commented Oct 14, 2020 at 9:57
  • $\begingroup$ Thank you for this detailed explanation. Could you elaborate as to why the components of the gradient are multiplied by the factor found in the square line element IE why is it $\frac 1{r^2} \frac \partial {\partial \theta} $ $\endgroup$ Commented Oct 14, 2020 at 21:16
  • $\begingroup$ The squared line element defines a metric on the space. It is the rule by which distances (and thus the rule by which everything else) is measured. If we want the gradient vector to be the same physical object no matter what coordinate system we choose, we have to find a way to compute its projection (length) along each of our basis vectors. The factor of $\frac{1}{r}$ or $\frac{1}{r^2}$ (depending on whether or not $\mathbf{e}_\theta$ is normalized) exists to ensure we are measuring length in a consistent way. $\endgroup$
    – vb628
    Commented Oct 14, 2020 at 22:50
  • $\begingroup$ does the square root give positive and negative values in $\frac{1}{\sqrt{r^2\sin^2\theta}}\frac{\partial f}{\partial \varphi}$? $\endgroup$
    – ananta
    Commented Nov 2, 2022 at 19:23

I am not satisfied with vb628's answer. Even after patryan asked for clarification, and vb628 responded, I am still uncertain why the scaling factors are what they are. Therfore, I undertake my own answer here.

$$\boldsymbol{\nabla}{f} = \mathbf{e}_r\, \frac{\partial{f}}{\partial{r}} + \mathbf{e}_\theta\,\frac{1}{r } \,\frac{\partial{f}}{\partial{\theta}} + \mathbf{e}_\phi\,\frac{1}{r\,\sin{\theta}} \,\frac{\partial{f}}{\partial{\phi}}\qquad\text{in spherical coordinates}.$$

To undertake this derivation I need the result that \begin{equation*} d\mathbf{s} = \mathbf{e}_r\,dr + \mathbf{e}_\theta\,r\,d\theta + \mathbf{e}_\phi\,r\, \sin{ \theta} \,d\phi . \end{equation*} Please note that $d\mathbf{s} \cdot d\mathbf{s} $ gives vb628's result for $ds^2$ found above. I also need to consider the differential arc length in each of the three directions of the standard spherical basis: \begin{align*} ds = \begin{cases} d\mathbf{s} \cdot\mathbf{e}_r =dr, & \text{when arc constrained to $\mathbf{ e }_r$ direction;} \\ d\mathbf{s} \cdot\mathbf{e}_\theta =r \,d\theta, & \text{when arc constrained to $\mathbf{ e }_\theta$ direction; and} \\ d\mathbf{s} \cdot\mathbf{e}_\phi =r\, \sin{ \theta} \,d\phi, & \text{when arc constrained to $\mathbf{ e }_\phi$ direction.} \end{cases} \end{align*}

According to the definition in [1], $\boldsymbol{\nabla}{f}$ in a direction $\mathbf{u}$ is the directional derivative $df/ds$ in that direction. The element of the archlength $ds$ in the $\mathbf{ e }_r$ direction is $dr$, so $$\boldsymbol{\nabla}{f}\cdot \mathbf{e}_r = \frac{d{f}}{ds} = \frac{\partial{f}}{\partial{r}}.$$ Note that I replace the derivative with the partial derivative to re-enforce that the arc is constrained to one of the standard basis directions. Below, I will do the same thing twice more. Similarly, the element of the archlength $ds$ in the $\mathbf{ e }_\theta$ direction is $r\,d\theta$, so $$\boldsymbol{\nabla}{f}\cdot \mathbf{e}_\theta = \frac{d{f}}{ds} = \frac{\partial{f}}{r\,\partial{\theta}}.$$ Finaly, the element of the archlength $ds$ in the $\mathbf{ e }_\phi$ direction is $r\,\sin{\theta}\,d\phi$, so $$\boldsymbol{\nabla}{f}\cdot \mathbf{e}_\phi = \frac{\partial{f}}{r\,\sin{\theta}\,\partial{\phi}}.$$ Thus, in spherical coordinates, we have $$\boldsymbol{\nabla}{f} = \mathbf{e}_r\, \frac{\partial{f}}{\partial{r}} + \mathbf{e}_\theta\,\frac{1}{r } \,\frac{\partial{f}}{\partial{\theta}} + \mathbf{e}_\phi\,\frac{1}{r\,\sin{\theta}} \,\frac{\partial{f}}{\partial{\phi}}$$


[1] Wikipedia contributors. (2021, January 14). Gradient. In Wikipedia, The Free Encyclopedia. Retrieved 21:38, January 27, 2021, from https://en.wikipedia.org/w/index.php?title=Gradient&oldid=1000232587

  • $\begingroup$ are the unit vectors normalized, because I was multiplying by the inverse metric tensor components and somehow got wrong answers $\endgroup$ Commented Jul 15, 2022 at 11:15
  • $\begingroup$ The vectors $ \mathbf{e}_r $, $\mathbf{e}_\theta$, and $\mathbf{e}_\phi$ form an orthonormal set in three dimensional space. $\endgroup$ Commented Jul 15, 2022 at 11:36
  • $\begingroup$ thanks, originally I did not normalize the basis, and when I asked unit, I meant basis. $\endgroup$ Commented Jul 15, 2022 at 11:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .