The electrostatic potential due to a point charge at the origin is given by: \begin{equation*} V=\frac{1}{4\pi\epsilon_0} \frac{q}{r} \end{equation*}
In rectangular coordinates, \begin{align*} \vec{r} &= x\hat{x}+y\hat{y}+z\hat{z}\\ r &= \sqrt{x^2+y^2+z^2} \end{align*} Thus, \begin{align*} \vec{\nabla}\left(\frac{1}{r}\right) &= \vec{\nabla}\left(\frac{1}{\sqrt{x^2 + y^2 + z^2}}\right) \\ &= \frac{\partial}{\partial x} \left( \left(x^2 + y^2 + z^2\right)^{-1/2} \right) \,\hat{x} + ... \\ &= -{\frac{1}{2}} \left(x^2 + y^2 + z^2\right)^{-3/2} \frac{\partial}{\partial x} \left(x^2\right) \,\hat{x} + ... \\ &= - {\frac{ x\,\hat{x} + y\,\hat{y} + z\,\hat{z}}{ \big(x^2 + y^2 + z^2\big)^{3/2} }}\\ &= - \frac{\vec{r}}{r^3} \end{align*} which shows that \(\vec{\nabla} V = -\vec{E}\), as expected.
This computation can be simplified using the chain rule, since \begin{equation*} \vec{\nabla} \left( h^{-1/2} \right) = -\frac{1}{2} \,h^{-3/2} \> \vec{\nabla} h \end{equation*} Here \(h = x^2 + y^2 + z^2\), so \begin{align*} \vec{\nabla} h &= 2x\,\hat{x} + 2y\,\hat{y} + 2z\,\hat{z}\\ &= 2\vec{r} \end{align*} which leads to the same result.
In spherical coordinates, \begin{align*} \vec{r} &= r\hat{r}\\ r &= \sqrt{r^2} \end{align*} (Why are there no \(\theta\)s or \(\phi\)s in these expressions? Hint: Think about \(\vec{r}\) as a set of directions to get from the origin to another point. Where do the basis vectors live?) Make sure to use the spherical coordinate formula for gradient: \begin{equation*} \vec{\nabla} f=\frac{\partial f}{\partial r}\; \hat{r} + \frac{1}{r}\frac{\partial f}{\partial \theta}\; \hat{\theta} + \frac{1}{r\sin\theta}\frac{\partial f}{\partial \phi}\; \hat{\phi} \end{equation*} Thus, \begin{align*} \vec{\nabla}\left(\frac{1}{r}\right) &= \vec{\nabla}\left(\frac{1}{\sqrt{r^2}}\right) \\ &= \frac{\partial}{\partial r} \left( r^{-1} \right) \,\hat{r} + ... \\ &= - \left(r\right)^{-2} \,\hat{r}\\ &= - \> \frac{\hat{r}}{r^2} \end{align*} which shows that \(\vec{\nabla} V = -\vec{E}\), as expected.
In cylindrical coordinates, \begin{align*} \vec{r} &= s\hat{s}+z\hat{z}\\ r &= \sqrt{s^2+z^2} \end{align*} (Why are there no \(\phi\)'s in these expressions? Hint: Think about \(\vec{r}\) as a set of directions to get from the origin to another point.) Make sure to use the cylindrical coordinate formula for nablaient: \begin{equation*} \vec{\nabla} f=\frac{\partial f}{\partial s}\; \hat{s} + \frac{1}{s}\frac{\partial f}{\partial \phi}\; \hat{\phi} + \frac{\partial f}{\partial z}\; \hat{z} \end{equation*} Thus, \begin{align*} \vec{\nabla}\left(\frac{1}{r}\right) &= \vec{\nabla}\left(\frac{1}{\sqrt{s^2 + z^2}}\right) \\ &= \frac{\partial}{\partial s} \left( \left(s^2 + z^2\right)^{-1/2} \right) \,\hat{s} + ... \\ &= -{\frac{1}{2}} \left(s^2 + z^2\right)^{-3/2} {\frac{\partial}{\partial s}} \left(s^2\right) \,\hat{s} + ... \\ &= - {\frac{ s\,\hat{s} + z\,\hat{z}} {\big(s^2 + z^2\big)^{3/2} }}\\ &= - \> \frac{\vec{r}}{r^3} \end{align*} which shows that \(\vec{\nabla} = -\vec{E}\), as expected.
This computation can be simplified using the chain rule, since \begin{equation*} \vec{\nabla} \left( h^{-1/2} \right) = -{\frac{1}{2}} \,h^{-3/2} \> \vec{\nabla} h \end{equation*} Here \(h = s^2 + z^2\), so \begin{align*} \vec{\nabla} h &= 2s\,\hat{s} + 2z\,\hat{z}\\ &= 2\vec{r} \end{align*} which leads to the same result.
Find the electric field around an infinite, uniformly charged, straight wire, starting from the following expression for the electrostatic potential: \begin{equation*} V(\vec r)=\frac{2\lambda}{4\pi\epsilon_0}\, \ln\left( \frac{ s_0}{s} \right) \end{equation*}
From the expression for \(V\), we can find the electric field: \begin{align*} \vec E &= -\vec\nabla V\\ &= -\frac{2\lambda}{4\pi\epsilon_0}\, \frac{\partial}{\partial s} \left(\ln\left(\frac{s_0}{s}\right)\right)\, \hat s\\ &= -\frac{2\lambda}{4\pi\epsilon_0}\,\frac{s}{s_0} \left(-\frac{s_0}{s^2}\right)\hat s\\ &= \frac{2\lambda}{4\pi\epsilon_0}\,\frac{\hat s}{s} \end{align*}
Notice that the dependence on the zero of potential \(s_0\) has disappeared, as expected.
This result matches the result found by finding the electric field from Coulomb's Law and direct integration.
The line segment lies along the z-axis, and I'm finding the electric field some distance \(s\) away from the center of the line segment. I'll use cylindrical coordinates to compute the electric field.
The vector pointing toward the point where the potential is evaluated is: \begin{equation} \vec{r} = s\,\hat{s} \end{equation} (If I wanted to, I could rewrite \(\vec{r} = s\cos{\phi}\,\hat{x}+s\sin{\phi}\,\hat{y}\) with Cartesian basis vectors, but this is unnecessary since \(\hat{s}\) doesn't change direction when I integrate.) The vector pointing toward an infinitesimal piece of charge is: \begin{equation} \vec{r'} = z'\hat{z} \end{equation} The electric field is: \begin{align} \vec{E} &= \int_{-L}^{L} \frac{k\lambda\, (\vec{r}-\vec{r}\,')\,ds'}{|\vec{r}-\vec{r'}|^3}\\ &= \int_{-L}^{L} \frac{k\lambda\, (s\, \hat {s}-z'\hat{z})\,dz'}{(s^2+z'^2)^{3/2}} \end{align}
I can break the integral into two pieces that can be integrated separately. The first integral, which points in the \(\hat{z}\)-direction, is an odd integrand (in the variable \(z'\)) integrated over an even region and is therefore zero. What symmetry of the physical situation corresponds to this mathematical symmetry? \begin{align} \vec{E_z} &= \lim_{L\to\infty} \int_{-L}^{L} \frac{-k\lambda\, z'\, \hat{z}\,dz'}{(s^2+z^2)^{3/2}}\\ &=0 \end{align} So, perpendicularly outward from the midpoint of the rod, there is no component of the electric field pointing parallel to the wire; the field points radially away from the wire. (This would not be true at other points in space.)
Therefore, the only non-zero contribution comes from the value of the second integral, which points only in the \(\hat{s}\) direction: \begin{align} \vec{E} &= \int_{-L}^{L} \frac{k\lambda\, s\, dz'}{(s^2+z'^2)^{3/2}}\, \hat{s}\\ &= \left[ \left. \frac{s\, z'}{s^2\;(s^2+z'^2)^{1/2}} \right|_{-L}^{L}\right]\, \hat{s}\\ &= \frac{2Lk\lambda}{s\;(s^2+L^2)^{1/2}}\, \hat{s} \end{align}
I've already solved for the electric field for a finite rod. \begin{equation} \vec{E} =\frac{2Lk\lambda}{s\;(s^2+L^2)^{1/2}}\,\hat{s} \end{equation} so all I have to do is take the limit of this expression as \(L\) goes to infinity.
There are a couple of options for evaluating this limit. One is to expand it in a power series of \(s^2/L^2\): \begin{equation} \vec{E} = \lim_{L\rightarrow\infty}\frac{2Lk\lambda}{s}\; \frac{1}{L}\; \left(1-\frac{1}{2}\,\frac{s}{L^2}+\ldots\right)\, \hat{s} \end{equation}
The \(L\)'s cancel, and in taking the limit, all the terms in the series disappear except the first term: \begin{equation} \vec{E} = \frac{2k\lambda}{s}\, \hat{s} \end{equation}
Another method is to recognize that, when \(L>>s\), then \((s^2+L^2)^{1/2}\approx L\) so that \begin{align} \vec{E}&=\lim_{L\rightarrow\infty}\frac{2Lk\lambda}{s\;(s^2+L^2)^{1/2}}\,\hat{s}\\ &=\frac{2k\lambda}{s}\, \hat{s} \end{align}