Integrals of the following form show up frequently in Physics, especially in electrodynamics. I have the following integral that I have no idea how to approach solving it:
$$\int_{-\infty}^{\infty}\left[\frac{1}{\sqrt{(x-x')^2+(y-a)^2+z^2}}-\frac{1}{\sqrt{x'^2+a^2}}\right]dx'.$$
I can solve each of them separately, or look them up in table integrals, but, the caveat is that separately, the integrals diverge, but as a whole, the integral converges. The only way I have been able to solve this is via Walfram Alpha and only with numbers--that is, replacing $z^2$ by 4 say and trying to figure out what goes where in the final answer.
I would love for someone to guide me as to how I can solve this integral exactly on paper. Additionally, could someone explain why the integral diverges when analyzed separately compared to when analyzed as a whole? This seems to break the general rule:
$$\int_a^b[f(x)+g(x)]dx=\int_a^bf(x)dx+\int_a^bg(x)dx.$$
[Perhaps some condition such as smoothness or continuity of functions is being broken in the presented case, but I am not sure.]
To find $$\int \frac{1}{\sqrt{u^2+a^2}} du$$ (a > 0), let $x = a \tan \theta$, Then $dx = a \sec^2 \theta d \theta$, and $\sqrt{u^2+a^2} = a \sec \theta$ (here we are using the identity $\sec^2 \theta = 1 + \tan^2 \theta$). This transforms the integral to $$\int \frac{a \sec^2 \theta}{a \sec \theta} d \theta = \int \sec \theta d \theta = \ln | \sec \theta + \tan \theta| = \ln | \frac{\sqrt{u^2+a^2}}{a}+\frac{u}{a}| + C.$$ Furthermore, properties of logs allow as to slurp the $a$'s in the denominator into the $+C$, so $$\int \frac{1}{\sqrt{u^2+a^2}} du = \ln | \sqrt{u^2+a^2}+u|+C$$
Now if we let $b = \sqrt{(y-a)^2+z^2}$, this and a simple substitution gives that your indefinite integral is equal to $$\ln | \sqrt{(x'-x)^2+b^2}+x'-x|-\ln|\sqrt{x'^2+a^2}+x'| + C = \ln|\frac{\sqrt{(x'-x)^2+b^2}+x'-x}{\sqrt{x'^2+a^2}+x'}| +C.$$ So if $f(x')$ is this expression, we want $\lim_{x' \to \infty} f(x') - \lim_{x' \to -\infty} f(x')$. It's a standard Calc I exercise to show that $\lim_{x' \to \infty} f(x') = \ln(1)=0$. To find $\lim_{x' \to -\infty} f(x')$ multiply the top and bottom by the conjugates of both the top and bottom to get $$f(x') = \ln|\frac{b^2}{a^2} \frac{\sqrt{x'^2+a^2} - x'}{\sqrt{(x'-x)^2+b^2}-(x'-x)}|.$$ Again the Calc I technique shows that $\lim_{x' \to -\infty} f(x') = \ln\frac{b^2}{a^2}$.
So your over answer is $-\ln(\frac{b^2}{a^2}) = 2 \ln(\frac{a}{b})= 2 \ln \frac{a}{\sqrt{(y-a)^2+z^2}}$.
To answer your second question, improper integrals are defined in terms of limits, and the limit law $$\lim_{x \to a} (f(x)+g(x))=\lim_{x\to a} f(x) + \lim_{x \to a} g(x)$$ only holds when both $\lim_{x\to a} f(x)$ and $\lim_{x\to a} g(x)$ exist.