Welcome to this last lecture in the seventh week of our course Analysis of a Complex Kind. In this lecture I'll show you how to evaluate an improper integral via the Residue Theorem. This is a real valued integral that doesn't look complex at all, and it's very hard to tackle using methods from real analysis. But it turns out, by turning to complex analysis, we can actually find this integral. Here's the integral we want to evaluate, the integral from 0 to infinity of cosine x / 1 + x squared dx. You can try all kinds of substitutions and techniques you know from calculus but it's really, really hard to practice integral. Let me quickly explain what all of these notation means. First of all when we write the integral from 0 to infinity, what that really means is we're taking the integral from 0 to R, where R is some large number and we're letting R go to infinity. And so we need to consider the integral from 0 to R of cosine x / 1 + x squared dx. Again this is a real valued integral, integral on the real axis. And then we need to let R go to infinity. Here's the next idea. The integral from 0 to R of this function cosine x / 1 + x squared is half of the integral when we go from -R to R. The reason is that the function cosine x / 1 + x squared is an even function. Look at this picture. Here you can see the function of cosine x / 1 + x squared from 0 to 10. The integral of this function is the area under the curve where areas above the x-axis count as positive, and areas below the x-axis count as negative. Now, look at what happens when we take the integral from -R to R instead. You see the function is symmetric, and so exactly the same areas are added up to the left of the origin as they are to the right of the origin. So that when I integrate from -R to R, instead of 0 to R, I get twice the value of the integral. So instead of integrating from 0 to R, I might just as well as integrate from -R to R to make things more symmetrical and then divide the result by 2. Here's the next idea. I can add an extra term in the numerator. The extra term I just added is i times sine x, and the claim is that didn't change anything. Why is that? Let's look at the function sine x / 1 + x squared. That function is an odd function. Look at this picture. For the function sine x / 1 + x squared, when I integrate it from 0 to R, I get the opposite value of the integral that I get when I integrated from -R to 0, because the function is odd. Whatever used to be above the x-axis, is now below the x-axis and vice versa. Areas to the left cancel out with areas to the right so that the integral from -R to R of sine x / 1 + x squared dx is equal to 0. Now, if I multiply this in addition by i, that doesn't change anything. Multiplying by i simply multiplies 0 by i, which is still 0. That's why I can simply add i times sine x in the integral here. But cosine x + i sine x, that's equal to e to the ix. And all of a sudden I get my exponential function into the picture here. So instead of finding the original integral from 0 to R of cosine x / 1 + x squared dx, I might just as well find one-half times the integral from -R to R of e to the ix / 1 + x squared. Here's the next idea. This integral from -R to R of e to the ix / 1 + x squared dx can be written as a complex contour integral. Namely as the integral over the line segment from -R to R of the function e to the iz / 1 + z squared dz. Why is that? This line segment from -R to R in the complex plane can be parameterized as gamma(x) equals x, where x goes from -R to R. And the derivative of this parameterization is simply 1. And so if I plug into this contour integral that part parameterization, this becomes one-half times the integral from -R to R of e to the i. And now I plug in gamma(x) for z. But gamma(x) is simply x / 1 + and again for z I plug in gamma(x), but gamma(x) is x, and then to multiply it with the derivative, gamma prime(x), which is 1, and take the integral dx. But, that's exactly the integral that we actually wanted to find. So the integral you want to find can be written as a complex contour integral. And that's what we want, because ultimately we really want to use the Residue Theorem. Currently, we're simply integrating over a line segment. We're going to have to integrate over a closed curve in order to be able to use the Residue theorem. So here's the next idea. This is the closed curve over which we're going to integrate. We're going to first integrate over the line segment from -R to R, and then go around this semi circle from R to -R. So that's R curve CR. CR is the line segment together with that semicircle gamma R. But that's clearly not the same thing as what we wanted before, we really only wanted to integrate over the line segment. So if we integrate over all of CR, which is the line segment plus the semicircle, then we need to subtract the integral over the semicircle afterwards, in order to make things right, and that's what we're doing right here. Now, the great thing is, what is the integral over the curve CR of the function, either the iz / 1 + z squared. E to the iz / 1+z squared has two singularities that are isolated. And the two singularities happen when the denominator of this function is equal to 0. When is the denominator equal to 0? When z is plus or minus I. Only this singularity at i's enclosed by the curve CR. The other singularity at -i is down here and we don't really care about it. So by the Residue Theorem, the integral over CR of the function e to the iz / 1 + z squared is 2 pi i times the residue of my function at the singular point. So here we have 2 pi i times the residue of my function at i. And the one-half, of course had to stay there. And then we need to subtract this integral over the semi circle. So we have two things to do. We need to find that residue of the function, e to the iz / 1+z squared at i, and then we need to take care of the integral over the semi circle. First we're going to find the residue of e to the iz / 1 + z squared at the singular point i. We notice that we have a simple pole at z equal to i because 1 + z squared factors into (z + i)(z- y). Therefore the residue can simply be found by multiplying f by (z- i) and then taking the limit as z approaches i. When I multiply f by (z- i) that (z- i) will cancel out with this other (z- i) in the denominator. And all that is left is then the z + i. So I need to find the limit as z approached i of e to the iz / z + i. I find that limit by simply plugging in i for z. When I plug in i for z I have an i squared in the exponent of the exponential function. So that's e to the -1 and then the denominator becomes 2i. So, that also is equal to 1 / 2ei. Therefore the integral over the closed curve CR, of either the iz / 1 + z squared ez, by the Residue Theorem is 2 pi i times the residue, the one-half you need to carry around right here. Here's the 2 pi i and here's the 1 / 2ie. I can cancel a few things out, so this 2 and that 2 for example, this i and that i, and now we're left with pi over 2e. Next I need to estimate the integral over the semi circle gamma R of my function f. Remember gamma R was simply the semi circle of radius R centered at the origin. Plus we're only really interested for what happens when R goes to infinity. What we want to show is that the integral actually goes to 0 as R goes to infinity, so it doesn't really matter then. In order to show that some complicated expression goes to 0 as R goes to infinity, really suffices to show that the absolute value of that complicated expression is bounded above by some constant for which it is easier for us to show that it goes to 0. So as long as this constant goes to 0, this integral, which is stuck between 0, and this constant that goes to 0 then is sandwiched in between 0 and the constant and therefore has to go to 0 as well. So we're going to try to find an upward bound for the absolute value of the integral and show that upper bound goes to 0, and then that integral is first to go to 0 as well. We need to show that the absolute value of the integral is bounded above by a constant wherer the constant goes to 0. How do we estimate the absolute value of an integral? Remember what we learned a while ago. The absolute value of a contour integral is bounded above by the length of the curve over which we're integrating times the maximum of the absolute value of f, for z's that are on the curve. So let's use that. So therefore in our case, the absolute value of the integral over gamma R of the function e to the iz / 1 + z squared is bounded above by the length of the curve gamma R, and that's pretty easy to find. The length of the curve gamma R, it's a semicircle of radius R. So it's pi R times the maximum of e to the iz / 1 + z squared. So how are we going to estimate that? First I need to look at the absolute value of e to the iz. Let's write z as x + iy. Then e to the iz becomes e to the ix + i squared y, so -y. Now remember the absolute value of e to the something, is e to the real part of the exponent. And what is the real part of ix- y? The real part of that is simply -y. So the absent value of e to the iz is e to the -y. The denominator is simply the absolute value of 1 + z squared. And here we use the reverse triangle inequality, the absolute value of 1 + z squared is greater than or equal to the absolute value of z squared- the absolute value of 1. The absolute value of z squared in that semi circle is always equal to R squared and so the denominator is bounded below by R squared -1. Since it's in the denominator, we found that 1 / the absolute value of 1 + z squared then is bounded above by 1 / R squared -1. And that's what you see right here. So the absolute value of my integrand is bounded above by e to the -y / R squared -1. Now, remember that we're only looking at the upper half of the circle of radius R, centered at the origin, so all my zs are from this upper half of the circle. Which means the y value of all of the zs is greater than or equal to 0. Because the y value is greater than or equal to 0, all these exponents -y are less than or equal to 0. Which means e to such an exponent is never greater than e to the 0, just 1. Therefore, on the curve gamma R, the integrand is bounded above by 1 / R squared -1. So we have seen that the absolute value of the integral is bounded above by the length of the curve, which was pi R, times the maximum of the integrand, which was 1 / R squared -1. And what happens to this product as R goes to infinity? Well the denominator goes to infinity much faster than the numerator. R squared wins over R, and therefore this whole fraction, pi R / R squared -1, goes to 0 as R goes to infinity, and that's what we wanted to show. Therefore, the integral of e to the iz / 1 + z squared over the curve gamma R goes to 0 as R goes to infinity. Now it's time to put it all together. Remember we wanted to find the integral from 0 to infinity of cosine x / 1 + x squared. Here's what we have. We first realized that instead of taking the integral from 0 to infinity, we need to take the integral from 0 to R and then let R go to infinity. Next we realized that instead of taking the integral from 0 to R of cosine x / 1 + x squared dx, we can turn this into something complex, and we integrate over the function e to the iz / 1 + z squared. We integrate it over the whole curve CR, which consisted of the line segment from -R to R and the semicircle gamma R. Next we showed that the integral over the closed curve CR of e to the iz / 1 + z squared dz is one-half times 2 pi i times the residue of the function at i, and that turned out to be pi / 2e. So this integral right here, that evaluated to pi / 2e. Next we showed that the integral over gamma R of e to the iz / 1 + z squared dz goes to 0 as R goes to infinity. So this integral right here, that goes to 0 as R goes to infinity. Therefore, as R goes to infinity, this integral here converges to pi / 2e, the value of the first integral over CR, because the second integral simply goes to 0. And so we have just shown that integral of cosine x / 1 + x squared from 0 to infinity is equal to pi / 2e. This is a fabulous result, as the outcome of the equation includes some of the most important mathematical constants namely pi, 2, only even prime number, and e. I hope you enjoyed this course, it's been a pleasure teaching you all.