Direction of $d\mathbf{l}$ A solid sphere has charge $q$ and radius $R$. Find the potential at a point a distance $r$ from the center of the sphere where $r>R$, using infinity as the reference point.
My attempt:
From Gauss' theorem we may deduce that $\displaystyle\mathbf{E}=\frac{1}{4\pi\epsilon_0}\frac{q}{r'^2}\hat{\mathbf{r}}$ where $r'$ is the distance of an arbitrary point from the center of the sphere provided $r'>R$.
$V=-\int_\infty^\mathbf{r}\mathbf{E}\cdot d\mathbf{l}$
My question: What is $d\mathbf{l}$? Since we are traversing in the direction opposite to $\hat{\mathbf{r}}$, I think it should be $-dr'\hat{\mathbf{r}}$. But when I use it to find $V$, I get a sign error. Please help!
 A: I am going to contradict the answers by @Bio (whose answer has since been deleted) and @lineage and say that $\text d\mathbf l$ is actually $\text d r'\hat{r}$ The other answers are mathematically correct, but it goes against our physical intuition with how the limits of integration are set up, as it seems you were discussing in the comments of the answer.
Indeed, it would be nice if our lower limit of integration was where we started and the upper limit was where we ended. This makes so much more sense if we make $\text d\mathbf l=\text d r'\hat{r}$. This is because the sign of $\text dr'$ is actually determined by our limits already. In general, if we are integrating from $r'=a$ to $r'=b$ we will have 
$$\Delta V=-\int_a^bE_r\text dr'$$
If $b>a$ then $\text dr'$ is positive, and if $b<a$ (which is what you are looking at) then $\text dr'$ is negative. The sign is already taken care of depending on how you set up the limits! You don't need to explicitly put in the sign of $\text dr'$
This is why in @Bio's answer (as well as @lineage's answer I believe, although that answer is very convoluted, so I am unsure) you need to switch the limits of integration. That way you are doing two sign changes, resulting in the same integral. While this is mathematically correct, I feel like you really lose the physical intuition of adding up these values as you move from the start to the end of the path. @Bio's integral is technically moving backwards along the path while adding up the negative of the values given by the integrand, thus yielding the same result.
A: When you are evaluating $\vec E \cdot \Delta \vec l$ you are really evaluating work done on a unit positive charge by an external force $\vec E$ when the displacement of the force is $\Delta\vec l = \vec r _{\rm final} - \vec r_{\rm initial}$.
This is the area under a force against displacement graph, the complication being that $\vec E$ varies with position.  
If $\vec E = E \,\hat r$ and $\Delta \vec l = (r _{\rm final} - r_{\rm initial})\,\hat r$ and remembering that $E$ varies with position $\vec E \cdot \Delta\vec l \approx E \,(r _{\rm final} - r_{\rm initial})= E\, \Delta r$.
Note here that I am not interested in the exactly magnitude of this quantity but I am very interested as to whether its value is positive or negative.
So let's look at the graph of $E$ against $r$.  
 
What is the area under this graph $\approx E \,(r _{\rm final} - r_{\rm initial})$?
You will immediately see that it depends on whether you follow the gray labels ($r$ increasing) or the red labels ($r$ decreasing).  
With the grey labels the area is positive because $r _{\rm final} - r_{\rm initial} > 0$, ie $\Delta r >0$, and $E$ is positive whereas with the red labels the area is negative because $r _{\rm final} - r_{\rm initial} < 0$, ie $\Delta r <0$,  and $E$ is positive.  
The way you evaluate this area exactly is by evaluating an integral $\int^{r_{\rm final}}_{r_{\rm initial}}E \,dr$ which is just the limit as $\Delta r$ tends to zero of a sum with terms like $E \,(r _{\rm final} - r_{\rm initial}) = E \,\Delta r$.  
And is  $(r _{\rm final} - r_{\rm initial})=\Delta r$ positive or negative in this sum?
That is completely determined by the limits of integration.  
So you must write $d \vec l = dr \,\hat r$ and the sign of $dr$ will be determined by the limits of integration.  
In your example, with the lower limit as infinity and the upper limit as $r$, the integral is negative (ie the process of integration is "using" negative $dr$)  and so the change in the potential is positive as expected.
A: Potential is defined as the negative of the work done in moving unit charge at zero acceleration from reference to that point in field where the potential is being calculated. So dl represents a differential movement from reference (here infinity) towards r' (assumed straight line path, else tangential to path towards r'). On the other hand, since r' is being measured from origin so its differential dr' is directed in the incresing direction of r'--from r' towards reference point(infinity). Hence, if the path connecting the two points between which the test charge is being moved is a straight line, the differentials only differ in sign so that dr'=-dl.
Hence 
$$V
=-\int_\mathbf{reference}^\mathbf{target}\mathbf{E(r').}\,\mathbf{dl}
$$
At this point instead of proceeding as 
$$
\begin{align}
V
&=-\int_\mathbf{\infty}^\mathbf{r}\mathbf{E(r').}\,\mathbf{dl}\\
&=-\int_\mathbf{-\infty}^\mathbf{-r}\mathbf{E(r').}\,(-\mathbf{dr'})\\
&=\int_{-\infty}^{-r}\frac{1}{4 \pi \epsilon_0} \frac{q}{r'^2} \,dr'\\
&=\frac{1}{4 \pi \epsilon_0} \frac{q}{r} \\
\end{align}
$$ 
most books follow (as @Bio suggests)
$$
\begin{align}
V
&=+\int_\mathbf{target}^\mathbf{reference}\mathbf{E(r').}\,\mathbf{dr'}\\
&=\int_\mathbf{r}^\mathbf{\infty}\mathbf{E(r').}\,\mathbf{dr'}\\
&=\int_r^\infty\frac{1}{4 \pi \epsilon_0} \frac{q}{r'^2} \,dr\\
&=\frac{1}{4 \pi \epsilon_0} \frac{q}{r} \\
\end{align}
$$ 
This is imho, probably because in the former way there is an implicit substitution changing l to r' but without the proper use of limits(as in $lim_{}$), the negation in limits(as in $\int_a^b\,$) cannot be explained.
$$
\\
\\
\\
$$
This becomes clearer when one considers doing the integral this way--
$$
V=
-\int_\mathbf{reference}^\mathbf{target}\mathbf{E(l).}\,\mathbf{dl}
$$
Since there exists dl so must l. Hence it should be possible to do the RHS without converting to r' coords. Doing this is a bit tricky as the limits would be
$$
\begin{align}
\mathbf{reference}&=\mathbf{0}\\
\mathbf{target}&=\lim_{h\to \infty}(h-r)\mathbf{\hat{l}}\\
\end{align}
$$
while 
$$
\mathbf{E(l)}=\lim_{h\to \infty}\frac{-1}{4\pi\epsilon_{0}}\frac{q\mathbf{\hat{l}}}{(h-l)^2}
$$
Then
$$
\begin{align}
V&=-\int_\mathbf{reference}^\mathbf{target}\mathbf{E(l).}\,\mathbf{dl}\\
&=-
\lim_{h\to \infty}
\int_
0^{h-r}
\lim_{h'\to h}
\frac{-1}{4\pi\epsilon_{0}}\frac{q\mathbf{\hat{l}.dl}}{(h'-l)^2}
\,\\
&=\frac{q}{4\pi\epsilon_{0}}\lim_{h\to \infty}\lim_{h'\to h}(\frac{1}{0-h'}+\frac{1}{h'-(h-r)})\\
&=\frac{1}{4 \pi \epsilon_0} \frac{q}{r}
\end{align}
$$
The integration performed in line 3 above is obtained from Mathematica as
$$
\int_a^b \frac{1}{(A-x)^2} \, dx=\frac{1}{a-A}+\frac
   {1}{A-b}, \quad\quad\quad(a\geq A\lor A\geq b)\land a<b
$$
A: The Potential is given by
$$ V_f - V_i = - \int_i^f \vec E.\, d\vec l$$
In this equation, as you go from $i$ to $f$ you will be taking infinitesimal distance dl along the vector $\vec E$. Because the path you take to go to infinity is radial, we can take $ d \vec l= d \vec r $.  It's easy to find potential when you take a charge from a distance R from a solid sphere(Charge $q$), where  $R> R'$, where R' is the radius of the sphere.
Take
$ f= \infty, \, i=R $ and solving you get,
$$V= \frac{q}{4 \pi \epsilon R}$$
So here's the twist when you consider finding that same potential at a distance $ R$ when bringing that charge from infinity.
Now $$d \vec l= - d \vec r$$
$$ f=R, i= \infty $$
But remember on an axis going through i to f, now you are coming back from f to i.
So,
$$ V_R - V_\infty = - \int_\infty^R \vec E.\, d\vec l$$
You substitute $-d\vec r$ for $d\vec l$.
But when you do so you must also change the limits of the integral because mathematically that integral would be negative of the actual value.
So, if you decide to show the opposite directions of vectors $r$ and $l$, you compensate for that by swapping the limits of integration. Think of it like this, if you are finding an area under a curve from $x=a$ to $x=b,\, b>a$ then, when you find area backward from $b$ to $a$, the area would be negative.
I am thinking this is of a similar case.
So when you take dr as negative of dl and keeping adding up those infinitesimal values dl from infinity to R, you will be getting a negative value of the actual answer because $d\vec l$ was always negative of $d \vec r$. So to compensate for that negative area we could swap the limits of the integral, essentially returning to the original area, or instead of swapping the limits you can negate the $-ve$ direction essentially allowing you to write $d \vec l= d \vec r$
So as mentioned by the others, your sign which was missing has already been attributed to limits of integral when you write d$ \vec l = d\vec r$
