How to "fix" $\int_{-1}^1 \frac {dx}{x^2}$ with complex numbers? Given the following definite integral, 
$$\int_{-1}^1 \frac {dx}{x^2}$$
I can see that it is an improper integral because of the asymptote at $x=0$ and I know from the graph of $\frac 1{x^2}$ that both parts on either side of the $y$-axis are identical. 
Hence, computing only the part on the right of the $y$-axis I find that the integral $\int_{-1}^1 \frac {dx}{x^2}$ is divergent since $-$as expected from the graph of $\frac 1{x^2}-$ this part goes to $\infty$:
$$\lim_{\epsilon\to 0^+}\int_{0+\epsilon}^1 \frac {dx}{x^2} \;=\; \lim_{\epsilon\to 0^+}-\frac 1x \;\bigg|_{\,0+\epsilon}^1 \;=\; -1-\left(\lim_{\epsilon\to 0^+}-\frac 1{0+\epsilon}\right) \;=\; \infty\;.$$
If I intentionally overlook that and blindly compute the integral, I get the silly result
$$\int_{-1}^1 \frac {dx}{x^2} = -2\;.$$
That is, a negative value for the area under a function that is above the $x$-axis everywhere. 
I was told that $\int_{-1}^1 \frac {dx}{x^2}$ can be "fixed" using imaginary numbers by a T.A. but neither of us had the time to expand on that point. 
I understand complex numbers and how they work so I am left to wonder; how can I "fix" an improper integral using complex numbers?
 A: A way to give a value to such integral is to consider a principal value:
$$\text{PV}\int_{-1}^{1}\frac{dx}{x^2}=\lim_{\varepsilon\to 0^+}\left(\int_{-1}^{-\varepsilon}\frac{dx}{x^2}+\int_{\varepsilon}^{1}\frac{dx}{x^2}\right)=\lim_{\varepsilon\to 0^+} 2\left(-1+\frac{1}{\varepsilon}\right)=+\infty. $$
In general, you may "integrate through singularities" by deforming the integration path, avoiding the singularities through arcs of circles with radius $\varepsilon$, then considering the limit as $\varepsilon\to 0^+$.
For instance $\text{PV}\int_{-1}^{1}\frac{dx}{x}=0$, even if $\frac{1}{x}$ is not integrable over $(-1,1)$, strictly speaking. 
A: Denote the path  $\Gamma$ on the real line with a deformed contour that approaches zero around the origin 

Consider the following function 
$$f(z) = \frac{1}{z^2}$$
Now to integrate 
$$\int_{\Gamma} \frac{dz}{z^2} = \lim_{\varepsilon\to 0^+}\left(\int_{-1}^{-\varepsilon}\frac{dx}{x^2}+\int_{\varepsilon}^{1}\frac{dx}{x^2} +\int_{C_{\varepsilon}} \frac{dz}{z^2}\,dz\right)$$
Note that 
$$\int_{C_{\varepsilon}} \frac{dz}{z^2}\,dz =-i \frac{1}{\varepsilon}\int^{\pi}_0 \frac{e^{i\theta}}{e^{2i\theta}} d \theta = -\frac{2}{\varepsilon} $$
This can be simplified to the following using the princpal value 
$$\int_{\Gamma} \frac{dz}{z^2} = \lim_{\varepsilon\to 0^+}\left(-2+\frac{2}{\varepsilon}-\frac{2}{\varepsilon}\right) = -2$$
EDIT:
I made a mistake in evaluating the limit around the semi-circle. 
A: You are right that the integral is infinity and there isn't anything complex variables is going to do to change this. However, going to the complex numbers allows us to consider related integrals that are finite.
We can imagine the integral you wrote down as an integral over a path along the real axis in the complex plane. The function $1/z^2$ has a divergence at the origin $z=0$ and the fact that the path goes through this point is what is making the integral come out to infinity. When considering a real variable, if you're trying to get from positive to negative territory, you have no choice but to go through the origin. However in the complex plane you can move the integration path so that it "goes around" the origin.
The simplest way to do this is to shift the integration path up slightly in the imaginary direction. To that end, we consider $$ \int_{-1}^1\frac{1}{(x-i\epsilon)^2}dx$$ where $\epsilon$ is some arbitrariliy small positive integer. Now that you aren't going through any bad points, it turns out that naive use of the usual rules of integration is valid and we get $$\int_{-1}^1 \frac{1}{(x-i\epsilon)^2}dx = \left.\frac{-1}{x-i\epsilon}\right|_{-1}^1=-\frac{1}{1-i\epsilon}-\frac{1}{1+i\epsilon} = -\frac{2}{1+\epsilon^2}.$$
If you take the limit $\epsilon \to 0$ of this result you get $-2,$ your wrong answer from above. This means that we have a limit and integral that don't commute: $$ -2=\lim_{\epsilon\to0} \int_{-1}^1 \frac{1}{(x-i\epsilon)^2}dx \ne \int_{-1}^1 \lim_{\epsilon\to 0}\frac{1}{(x-i\epsilon)^2}dx=\infty.$$
So the $-2$ does seem to have a special meaning for the integral, although it is not its value. In fact, what is going on is that the integral along any complex path from $-1$ to $1$ that does not go through the origin has the value $-2$ (the reason for this is similar to the reason why conservative vector fields have path-independent integrals, if you're familiar. The antiderivative $-1/z$ is like a potential field). Seriously, the integral over any complex path is $-2$ provided it starts and ends at $-1$ and $1$, no matter what it does in between... except if it touches the origin. I should add that this isn't the case with any integrand (just like not all vector fields are conservative).
Granted this rather amazing path-independence property, it's no longer surprising that we don't see any inkling of an infinite divergence as we take $\epsilon\to 0.$ None of those lines from $-1+i\epsilon$ to $1+i\epsilon$ pass through the origin, since we have path independence, the limit is just taking the endpoints down to $-1$ and $1$ and anything can happen in the middle except touching the origin.
Going back to the real integral at hand, we have its definition as an improper integral $$ \int_{-1}^1\frac{dx}{x^2} = \lim_{a,b\to 0^+} \int_{-1}^{-b}\frac{dx}{x^2}  + \int_a^1 \frac{dx}{x^2} = \lim_{a,b\to 0^+} -2 +\frac{1}{a}+\frac{1}{b} $$
which we can see takes the form $-2+\text{divergence}$ and in this case the divergence has a well-defined limit of $\infty.$ (Contrast this to the case where you're integrating, say, $1/x$ instead of $1/x^2$ and you'll see that the divergence takes the indeterminate form $\ln(a/b)$ so the improper integral does not exist.) So the $-2$ is sort of a residual when we disregard the divergence at the origin, in accord with it being the path-independent value of the complex integral.
Others have mentioned the Cauchy principal value which is a way of handling the divergence at the origin that is a little more forgiving than the improper integral since it restricts the above limit to be symmetric (i.e. along the line $a=b$) where behavior might be well-defined. Here, for the integral of $1/x^2,$ this just turns the divergence to $\lim_{a\to0^+} 2/a$ so we still just get infinity. (But in the case of $1/x$ mentioned above, the $\ln(a/b)$ becomes zero, which means the Cauchy principal value is defined.) Even though the principal value by this definition has no direct relationship to complex variables, it comes up so much in that arena that it is effectively part of that subject, so its possible this, and not the above path shifting, is what your TA was referring to, although as we've seen it does nothing for this particular integral.
However, the principal value is quite related to the integration along a particular complex path that avoids the divergence. Instead of shifting the whole path up as before, keep the path as normal from $-1$ until you get within a distance of $\epsilon$ of the origin, and then go around the origin in a semicircle. Then continue from $\epsilon$ to $1$ along the real axis. I'll take the semicircle above the origin rather than below, though it doesn't matter.
We know from path independence that this integral needs to come out to $-2$. We can split it up into two parts: the semicircle and the pieces along the real axis. The second part has the value $$ \int_{-1}^{-\epsilon}\frac{dx}{x^2}+ \int_\epsilon^1\frac{dx}{x^2} = -2+\frac{2}{\epsilon}$$ which we see is just like the principal value, only before you take the limit $\epsilon\to0.$ The integral around the semicircle must be $-2/\epsilon$ in order for the whole integral to come out to $-2$. So we see that the divergence from the principal part and the divergence from the integral around the circle cancel out. This gives a detailed view of how path independence is preserved for this integral, even when we get as close to the divergence as possible without touching it.
A: The function $f(z) = 1/z^2$ has anti-derivative $F(z) = -1/z$ everywhere in the complex plane except $z=0$.  If $\gamma$ is any contour in the complex plane that goes from $-1$ to $1$ and avoids $0$, then
$$
\int_\gamma f(z)\,dz = F(1) - F(-1)= -2.
$$
So of course we say
$$
\int_{-1}^1 \frac{dz}{z^2} = -2 .
$$
Most contour integrals are not independent of the path, and then you need to say more to specify what you mean by integral from $a$ to $b$.  For example,
$$
\int_{-1}^1 \frac{dz}{z}
$$
is nonsense, because the answer differs, depending on which contour going form $-1$ to $1$ you choose.
A: When you first looked at an integral like $\int_{-1}^{1}dx/x^2$, your instinct was to apply the fundamental theorem of calculus, and evaluate $[-1/x]|_{-1}^1$. This answer was clearly wrong, but why? Why does having a singularity in between screw up the fundamental theorem of calculus?
Well, you might have the intuition for the fundamental theorem of calculus as having to do with, e.g. a disk expanding outwards, and the derivative of the area being the circumference -- so with some $dr$ added to the radius, $2\pi r\cdot dr$ is added to the area. And with a lot of $dr$'s getting added, the total addition to the circumference -- the integral of $2\pi r$ across the total length of $dr$'s that got added -- is the difference in area over the expansion. 

But you might imagine a set-up where there's a singularity somewhere in the expansion, so the area suddenly blows up to infinity somewhere in between the expansion, then starts back from 0 1. Something's not quite wrong here. Our intuition just broke -- the actual amount of area that got added isn't the same as the total area change here.
Like in our exercise above, let's look at the antiderivative of $1/x^2$ between -1 and 1. And for comparison, we'll keep another function -- a normal, continuous function -- and its antiderivative.

And that's the fundamental problem here -- the integral is taking a different path (and if you wrapped the xy-plane around a sphere, you'd actually be able to visualise this path as going all the way to infinity then coming back from behind) from the $F(b)-F(a)$ calculation. $F(b)-F(a)$ is -2, but the path taken by the integral is in fact, $\infty-2$.
On the real line, there's no other path you can take (besides going to infinity and coming back) on which the integral is valid. But if you could just budge the path a bit "out" of the xy-plane, it would be valid, because you wouldn't be going to infinity -- just a really high number. An example way of doing this is to use complex numbers, since the added dimension allows you to draw the path between -1 and 1 a little out of the plane, and take the limit as this "little out" approaches 0. As an example, you can look at the integral:
$$\int_{-1}^1 \frac1{x^2+\epsilon}dx$$
(Explain why this integral may be interpreted as using the complex plane.)
In fact, it is quite natural to use the complex numbers as a way to "poke out" of the real line, since "integrals are done along curves, not between limits" is a central insight from complex calculus.
1 obviously, to be clear on this, we'll need to introduce some concept of time/a parameterisation t, and differentiate with respect to it instead, and claim that there is a singularity in $r(t)$.
A: When we are speaking about the function $f(x)=\frac1{x^2}$ we can mean two different things:

*

*$\,f_1(x)={\begin{cases}0,&{\mbox{if }}x=0\\\frac1{x^2},&{\mbox{otherwise}}\end{cases}}$


*We consider $f_2(x)$ as a holomorphic function.
If we integrate the first case, we get the principal value and it will be infinite:
$$PV\int_{-1}^1\frac{dx}{x^2}=\infty$$
If we integrate the second case, we will get the Hadamard finite part and it will be $-2$:
$$\operatorname{f.p.}\int_{-1}^1\frac{dx}{x^2}=-2$$
Now, what happens? I will try to explain in simple language.
If we take the first case, the integral $\int_{-\infty}^\infty f_1(x)dx$ is equal to $\int_{-\infty}^\infty 1 dx = 2\pi\delta(0)$ formally (or germ of $\frac2x$ at $x\to 0^+$) which can be seen from the Laplace transform. This integral has the regularized value of $0$.
Since $\int_1^\infty \frac1{x^2} dx=1$, the integral $\int_{-1}^1 f_1(x)dx$ has the regularized value $-2$. We can write it formally as $2\pi\delta(0)-2$.
Lets now consider the second case.
Here, the function has singularity at zero... and that singularity behaves in such a way as if it was infinitely negative, so it balances out the other parts of the function:
$\int_{-\infty}^\infty f_2(x)dx=0$
This is analogous to the imaginary jump the logarithmic function has at zero, except in this case the jump is infinite (and not imaginary).
So, $\int_{-1}^1 f_2(x)dx=-2$.
This, second case is used in tables of Fourier transforms, for instance.
