Deriving the characteristic function of the Cauchy distribution. I am having trouble understanding this derivation of the characteristic function of the Cauchy distribution. Specifically the last step
I noticed identity $x^{2}+a^{2} = (x-ai)(x+ai)$ and plugged it in to $p(x)$, giving me 
splitting the term $p(x)$ as:
$$p(x)=\frac{a}{\pi(x-ai)(x+ai)}$$
I then split $p(x)$ into two terms, as:
$$\frac{a}{\pi} \left ( \frac{1}{(x-ai)(x+ai)} \right ) =  \frac{a}{\pi} \left ( \frac{A}{(x-ai)}  + \frac{B}{(x+ai)} \right )$$
where $A$ and $B$ are constants (I used this approach a while back but forgot the name). To find these terms, I multiply the denominator for each term, giving me
$$1 = A(x+ai) + B(x-ai) = Ax + Bx + Aai-Bai$$
Given that $A=B$, I get $1=Ax + Bx = 2Ax $ and get $A=1/2x$. After plugging this in for $A$ and $B$ I get 
$$p(x) =  \frac{a}{2x\pi} \left ( \frac{1}{(x-ai)}  + \frac{1}{(x+ai)} \right )$$
If I plug in $p(x)$ and equate it to the solution I get 
$$\frac{a}{2\pi x} \left ( \frac{1}{x-ai}  + \frac{1}{x+ai}\right ) = \frac{1}{2\pi i}  \left [  \frac{1}{x-ia} - \frac{1}{x+ia} \right ]$$
But I don't see how these terms are equal and I'm not entirely sure that I've done the correct approach. Apologies if I'm getting the terminology wrong or if the result if super simple. I'm trying to teach myself some stat mech from Kardar and I don't work with characteristic functions or imaginary numbers much, so this derivation is giving me trouble.
 A: Start from your equation $1 = A(x+ai) + B(x-ai) = Ax + Bx + Aai-Bai$. 
Left hand side is a constant that does not depend on $x$. So all terms in r.h.s. containing $x$ should annihilate. Therefore $$A+B=0,$$
$$A=-B,$$
$$-2Bai=1,$$
$$B=-\frac{1}{2ai}$$ 
and $$A=\frac{1}{2ai}.$$
A: $A,\,B$ need to each be constant, so $A=\frac{1}{2x}$ is a sign you took a wrong turn. Solving $(A+B)x+(A-B)ai=1$ as per @NCh's answer agrees with$$\frac{1}{x-ia}-\frac{1}{x+ia}=\frac{x+ia}{x^2+a^2}-\frac{x-ia}{x^2+a^2}=\frac{2ia}{x^2+a^2}.$$The pdf $\frac{a\pi^{-1}}{x^2+a^2}=\frac{\pi}{2i}\left(\frac{1}{x-ia}-\frac{1}{x+ia}\right)$ isn't the most general Cauchy distribution; that's $\frac{a\pi^{-1}}{(x-x_0)^2+a^2}$. The case $x_0=0$ is all we need, as more generally we multiply the characteristic function by $\exp ix_0k$. Mind you, going from the "standard" PDF with $a=1$ to this case is achieved by replacing $k$ with $ak$, so let's consider that:$$\int_{\Bbb R}\frac{\pi^{-1}\exp ikxdx}{x^2+1}=\sum_\pm\pm\int_{\Bbb R}\frac{\exp ikx}{x\mp i}\frac{dx}{2\pi i}.$$We can evaluate this when $k>0$ with the residue theorem, using the ever-popular $R\to\infty$ clockwise semicircular contour with a diameter on the real axis. This encloses the pole $i$, and as $z\to\infty$ with $\Im z>0$ we find $\exp ikx\to0$. So the result is$$\left.\exp ikx\right|_{x=i}=\exp -k.$$When $k=0$, we just get $1$ by the PDF's unitarity; when $k<0$, changing the sign of $k$ conjugates the characteristic function. So in general, it's $\exp -|k|$. (In other words, your original distribution has characteristic function $\exp-a|k|$, since $a>0$.)
You can also verify this gives the original PDF by the inversion theorem, i.e. that$$\int_{\Bbb R}\frac{1}{2\pi}\exp(-a|k|-ikx)dk=\frac{a\pi^{-1}}{x^2+a^2}.$$Indeed,$$\begin{align}\int_{-\infty}^0\frac{1}{2\pi}\exp(-a|k|-ikx)dk&=\int_0^\infty\frac{1}{2\pi}\exp(-(a-ix)k)dk\\&=\frac{1}{2\pi}\frac{1}{a-ix},\\\int_0^\infty\frac{1}{2\pi}\exp(-a|k|-ikx)dk&=\frac{1}{2\pi}\frac{1}{a+ix},\\\int_{\Bbb R}\frac{1}{2\pi}\exp(-a|k|-ikx)dk&=\frac{1}{2\pi}\frac{2a}{a^2+x^2}=\frac{a\pi^{-1}}{a^2+x^2}.\end{align}$$
