Valid proof for integral of $1/(x^2+a^2)$ I'm trying to prove some integral table formulae and had a concern over my proof of the following formula:
$$\int\frac{1}{x^2+a^2}\;dx=\frac{1}{a}\arctan\left(\frac{x}{a}\right)+C$$
Claim:
$$\frac{1}{x^2+a^2}=\frac{1}{a^2}\sum_{k=1}^\infty(-1)^{k-1}\left(\frac{x}{a}\right)^{2k}\hspace{5mm}\forall\;x\in(-a,a)$$
Proof:
$$\frac{1}{x^2+a^2}=\frac{1}{a^2}-\frac{x^2}{a^4}+\frac{x^4}{a^6}-\frac{x^6}{a^8}+\dots$$
$$\implies 1=(x^2+a^2)\left(\frac{1}{a^2}-\frac{x^2}{a^4}+\frac{x^4}{a^6}-\frac{x^6}{a^8}+\dots\right)$$
$$\implies 1=\left(\frac{x^2}{a^2}-\frac{x^4}{a^4}+\frac{x^6}{a^6}-\frac{x^8}{a^8}+\dots\right)+\left(1-\frac{x^2}{a^2}+\frac{x^4}{a^4}-\frac{x^6}{a^6}+\dots\right)$$
$$\implies 1=1\hspace{5mm}\forall\;x\in(-a,a)$$
My proof then uses the following:
$$\int\frac{1}{x^2+a^2}\;dx=\frac{1}{a^2}\int\sum_{k=1}^\infty(-1)^{k-1}\left(\frac{x}{a}\right)^{2k}\;dx=\frac{1}{a}\arctan\left(\frac{x}{a}\right)+C$$
My concern is that this isn't a valid proof since the radius of convergence of arctangent's Taylor Series is finite. I'm 7 years removed from taking calculus so I'm admittedly forgetful of the fine details on this. Could someone explain if this is a valid approach or, if not, why?
 A: It’s valid for $|x|\leq 1$ due to the uniform convergence of the Taylor series you obtain after integrating to arctan, but not outside this interval and has to do with not being able to pull that sum outside the integral on this region. I can give you a simpler way to integrate this if you’d like?
A: The usual attack for this integral is to "pull a rabbit out of a hat":  most books will say something like

Hey, remember back in Chapter 4 where we used the inverse function theorem to prove that
$$\frac{\mathrm{d}}{\mathrm{d}x} \arctan(x) = \frac{1}{x^2 + 1}?$$
Well!  This automatically tells us that
$$\int \frac{1}{x^2 + 1} \,\mathrm{d}x = \arctan(x) + C.$$
Then make a change of variables to deal with
$$ \int \frac{1}{x^2 + a^2} \,\mathrm{d}x. $$
Isn't that easy?!

However, another approach is a trigonometric substitution:  to visualize this, take $\sqrt{x^2 + a^2}$ to be the hypotenuse of a right triangle with legs of length $a$ and $x$, and take $\theta$ to be the angle adjacent to the side of length $a$.

Then $$\cos(\theta) = \frac{a}{\sqrt{x^2+a^2}}
\implies
\frac{1}{x^2 + a^2} = \frac{1}{a^2} \cos(\theta)^2.$$
From the same triangle, $\tan(\theta) = \frac{x}{a}$, from which it follows that
$$ \sec(\theta)^2 \,\mathrm{d}\theta = \frac{1}{a} \,\mathrm{d}x
\implies \mathrm{d}x = a \sec(\theta)^2 \,\mathrm{d}\theta. $$
Making the change of variables,
$$ \int \frac{1}{x^2 + a^2}\,\mathrm{d}x
= \int \frac{1}{a^2} \cos(\theta)^2 \cdot a \sec(\theta)^2 \,\mathrm{d}\theta = \frac{1}{a} \int \,\mathrm{d}\theta = \frac{\theta}{a} + C.
$$
Recall that $\tan(\theta) = \frac{x}{a}$, which implies that $\theta = \arctan(\frac{x}{a}). $  Therefore
$$ \int \frac{1}{x^2 + a^2} \,\mathrm{d}x = \frac{1}{a} \arctan\!\left(\frac{x}{a}\right) + C.$$
One has to be a little careful to ensure that the hypotheses of the change of variables ($u$-substitution; integration by substitution) is justified, but this can be done.

If you want to approach the problem using power series, there are a couple of things which need to be done.  First, you seem to be assuming the conclusion from the start.  However, it is possible to obtain a power series expansion for
$$ \frac{1}{x^2 + a^2} $$
without assuming it from the start, so I'll skip this step.[1]  I will also assume that the power series expansion of $\arctan$ is already known—there are ways of doing this which aren't circular.
To finish this off, we can apply a result from complex analysis.  The theorem needed is the identity theorem:

Theorem:  Suppose that $f$ and $g$ are two complex functions which are defined on some domain $D$, $S\subset D$ has an accumulation point, and $f(z) = g(z)$ for all $z \in S$.  Then $f^{(n)}(z) = g^{(n)}(z)$ for all $z \in D$.

Take
$$ f(z) = \int \frac{1}{z^2 + a^2} \,\mathrm{d}z
\qquad\text{and}\qquad g(z) = \frac{1}{a} \arctan\!\left(\frac{z}{a}\right), $$
both of which are entire functions (they are complex differentiable on all of $\mathbb{C}$).[2]
The argument presented in the question asserts that $f(z) = g(z)$ for any value of $z$ which falls into the disk of convergence for the power series.  This disk has lots of accumulation points, so take that to be the set $S$ in the identity theorem.
From this, it follows that the claimed identity holds on all of $\mathbb{C}$, which implies that it holds on $\mathbb{R}$ (since $\mathbb{R} \subseteq \mathbb{C}$).

[1] The usual approach is to start with the fact that
$$ \sum_{k=0}^{\infty} y^k = \frac{1}{1-y} $$
on the interval or disk of convergence, and then monkey around with the variables a little, e.g. take $y = -x^2/a^2$ or something similar.
[2] Technically, $f$ is an equivalence class of functions—choose the representative with $C = 0$, and don't worry too much about it.  Or take derivatives on both sides of the equation and take advantage of the uniqueness of antiderivatives up to an additive constant at the end.
A: This is what I call an almost immediate antiderivative, based on the fact that if $\;\int f(x)\,dx = F(x)\;$ , then we can conclude that $\;\int f(g(x)) g'(x)\,dx = F(g(x))\;$, which of course it's just the basis of substitution, and thus:
$$\int\frac{dx}{a^2+x^2}=\frac1a\int\frac{\frac1adx}{1+\left(\frac xa\right)^2}=\frac1a\int\frac{d\left(\frac xa\right)}{1+\left(\frac xa\right)^2}=\frac1a\arctan\frac xa+C$$
