Formalizing some items in an electrostatics computation Consider the question attached (Example 3.4 from Zangwill's Modern Electrodynamics, Ch 3). I can follow the solution quite easily using "physics math" but, having just recently finished Spivak's Calculus, I want to formalize the operations performed and am hoping someone can help me with two items in particular. Note that I will refer to the equations in the attached picture as (1) through (6), in the order they appear. The only niceties which I intend to ignore in this "formalization" are the rigorous developments of the improper integrals and also the $\epsilon_0$ factor. All integrands etc. are continuous so all of the theorems I invoke apply.

*

*For equation (3), I noted that Zangwill is choosing to evaluate the line integral along the path $ \boldsymbol\ell $ which is parametrized as $ \boldsymbol\ell  =  \boldsymbol\ell(r') = r' \mathbf{\hat{r}} $ in the conventional spherical coordinate system, and we are evaluating from $r'=\infty$ to $r' = r$. But I wanted to challenge myself to compute this line integral via the "opposite" path and to show that the same result obtains (as it must, since the line integral from a point to a point is independent of the parametrization of the path which we choose). Thus I tried to consider the parametrization $ \boldsymbol\ell  =  \boldsymbol\ell(u) = r'(u) \mathbf{\hat{r}} $ where $r'(u) = -u$ (perhaps this is my first error -- this was what I thought was appropriate for a path which "starts" at infinity and goes radially towards 0) where we go from $u = -\infty$ to $u = -r$. Thus $ d\boldsymbol\ell  =  \frac{d\boldsymbol\ell}{du}du = -\mathbf{\hat{r}}du $. Would this process be correct if I plugged it into the LHS equality of equation (3)?



*More importantly, I want to follow the u-substitution which is performed using the physicist shorthand of "changing the integration variable". More rigorously (I think), I could observe that the middle expression in equation (3) is written as (I change the integration variable to $x$ so there is no confusion with derivatives)
$$\int_\infty^r dx \ g'(x) (f\circ g)(x)$$
where
$$f (x) = \int_0^{1/x} ds \ s^2 \rho(s)$$
$$g(x) = 1/x$$
$$g'(x) = -1/x^2$$
so that by the u-sub theorem (Spivak Theorem 19-2) I have
$$\int_\infty^r dx \ g'(x) (f\circ g)(x) = \int_{g(\infty)}^{g(r)} dx f(x)=\int_{0}^{1/r} dx \int_0^{1/x} ds \ s^2 \rho(s)$$
Integrating by parts (Spivak Theorem 19-1), I find then that the integral is given by
$$\int_{g(\infty)}^{g(r)} dx f(x)=\int_{0}^{1/r} dx \int_0^{1/x} ds \ s^2 \rho(s) = \left(x\int_0^{1/x} ds \ s^2 \rho(s) \right)\Big|_0^{1/r} - \\ \int_{0}^{1/r} dx \ x (-1/x^2) (1/x)^2 \rho(1/x) = \frac{\int_0^{r} ds \ s^2 \rho(s)}{r} + \int_{0}^{1/r} dx \  \frac{\rho(1/x)}{x^3}$$
where in the last step I've tried to use the fundamental theorem of calculus (Spivak Theorem 14-1) and the chain rule to evaluate the derivative with respect to $x$ of the inner integral. I can then observe that the second term integral in the above has an integrand of the form necessary for u-substitution, with $f(x) = x \rho (x), g(x) = 1/x, g'(x) = -1/x^2$ so that I obtain
$$\frac{\int_0^{r} ds \ s^2 \rho(s)}{r} + \int_{0}^{1/r} dx \  \frac{\rho(1/x)}{x^3} = \frac{\int_0^{r} ds \ s^2 \rho(s)}{r} - \int_{\infty}^{r} dx \ x \rho(x) = \frac{\int_0^{r} ds \ s^2 \rho(s)}{r} + \\ \int_{r}^{\infty} dx \ x \rho(x) $$
which is the correct final answer.

I'm hoping someone can check and/or set me straight with both steps.

 A: *

*See Question about the sign of $\mathbf{E}\cdot d\mathbf{l} $when computing the Electric Potential for some remarks about the direction of the path, and its effect on signs (and indeed, you’re right that it doesn’t matter how you parametrize a path for line integrals of such conservative vector fields, as long as the endpoints are the same!, but the opposite path (i.e travsering a given path in the opposite direction) will yield a minus sign).

*There was no need to change variables at all. The only thing being done here is integration by parts (and the FTC to evaluate $f’(x)$ in what follows). Let $f(x)=\int_0^x\rho(s)s^2\,ds$ (different from your $f$), and $g(x)=\frac{1}{x}$. Then, the integral in the middle is
\begin{align}
\int_{\infty}^rf(x)g’(x)\,dx&=[f(x)g(x)]_{\infty}^r-\int_{\infty}^rf’(x)g(x)\,dx\\
&=\left[\frac{f(x)}{x}\right]_{\infty}^r-\int_{\infty}^r[\rho(x)x^2]\cdot\frac{1}{x}\,dx\\
&=\frac{f(r)}{r}-0-\int_{\infty}^rx\rho(x)\,dx\\
&=\frac{1}{r}\int_0^r\rho(s)s^2\,ds+\int_r^{\infty}x\rho(x)\,dx.
\end{align}
If you think about what you did, you made one change of variables, then you undid it, which is why your approach is longer than necessary.

