this video is sponsored by data cam an online platform to learn data science for real integration there are two kinds of intuition the most common one is area under a graph so if the function is f ofx then the area is the integral here the other intuition is a little more physical the mass of a Long Rod which spans from A to B this is basically just thinking of f ofx as a density function however the basic idea behind these two views are the same it can be thought of as a sum of lots of components here they are areas of rectangular strips the height is f ofx the function value at that point and the width is a small increment in X say DX so the integral here is just summing up all the F ofx DX I mean after all this symbol is just a long s s for some for the rod intuition the integral just represents summing up masses of these little rods F ofx represents the density of the rod at that point and DX is the length of the little Rod we are going to replicate the concept of summing up little things for complex integration however this is slightly more complicated generalizing the integrant isn't difficult simply replace it with a complex function so in our Rod intuition we have to think of the density as a complex function weird but still roll with it next up we have to change our DX to DZ a complex increment but what does that even mean well focus on that tiny rod with length DX in the complex analog DZ would mean a small complex increment so the length is a complex number now the final thing to generalize would be the upper and lower limits the thing is we can't just let these limits be complex and call it a day the difference here is that in our previous case for real integration saying from A to B isn't ambiguous there can just be one direction to go however in the complex World saying from A to B is not specific enough because we are on a plane now the straight line path is just one of the options and you can also have a curved rod from A to B and the thing is that integrating along different curves could be different so we have to specify the path taken so let's denote this curved path to be gamma and the integral along gamma is denoted like this this directed path is called a contour usually though we will be dealing with closed loops and in this case we can use a fancier integration symbol to say that we are working on a closed Contour but honestly as long as you specified your curve gamma correctly the original one is still fine so that's essentially the definition of complex integration but the thing is how do we compute this I mean technically you can just repeat the definition and sum up all the DZ contributions but that's way too inefficient well one slightly better way is to do direct partiz it starts off like this well we don't know how to do complex things but we do know how to integrate real functions or rather even if the integrant f ofx is complex valued as long as we are integrating over the reals we can always just separate F ofx into its real and imaginary parts and integrate each part separately so what if somehow we can apply another function fee that transforms the real path over to the complex path then we can just focus on this familiar setting the process of finding fee is parametrization and so now the path is from V of a to V of B we wanted to compute the integral of f of Z DZ along this Contour gamma and we now want to replicate it in the real setting so for a given patch of the real world near a point x we should associate it with F of f of x because after the Fe transformation this will be the corresponding function value at that point the catch is that it is now a complex increment rather than just a real increment in the real case so we need to scale DX by something to get DZ from the intuition we developed on differentiation this is precisely the derivative of V at X so the complex integral is now represented just as a real integral to reiterate by the partiz that is simply V of X and a small complex increment DZ is related to DX by the scaling Factor V Prime of X and this well doesn't give us too much insight for now to have more insights we need to go to the second ch [Music] chapter I have mentioned Poli Vector field in those two videos but a brief recap wouldn't hurt for every Point Z on the complex plane we attach a vector corresponding to the value of f of Zed but conjugated more explicitly if we write Zed and F of Zed in their real and imaginary parts then the vector to be plotted with would be U minus V I think it might be worth pointing out that both u and v are actually functions of X and Y however if we directly attach such a vector to even just a selection of Zs the long vectors can clutter up the plot and so usually we standardize the length of the vectors and sometimes use colors if we really need to indicate the length but what is so special about this construction this will require a few steps of straightforward manipulation so pause if necessary first we will compute the Divergence of the resulting Vector field which can be thought of as this and then we get the difference of partial derivatives and a 2d curl of the same Vector field can be similarly calculated and this time it is the negative of a sum of these partial derivatives but if we put the two expressions together does it ring a bell they have something to do with the CR equations more precisely the first equation is equivalent to saying that the Divergence of the poar vector field is zero while the second one is equivalent to saying the 2D curl is zero to reiterate this if F satisfies the Koshi reman equations the Divergence and 2D curl of its poar Vector field are both zero isn't that amazing however this field has another use we are going to see right [Music] now let's go back to complex integration just like before we integrate from A to B through the path gamma and the integral tells us to sum the contributions by these little complex increments DZ but now think of the complex number F of Zed as a vector and DZ as a vector as well and focus on F of Z * DZ to do that we can consider the arguments of the two complex numbers let's say the argument of f of Z is Alpha and that of DZ is beta then multiplying them just means multiplying the modulus and adding up the arguments how's this going to help well enter poar Vector field the vector attached at this point is f bar with argument negative Alpha but the angle between FB bar and DZ is special if we call this angle Theta then it is precisely the difference between the angles beta and negative Alpha and in fact Theta is just Alpha plus beta let's clean things up for a bit the only angle we'll be dealing with from now on is Theta by Oilers formula we can rewrite e to I Theta now do the first term here ring a bell multiplying the magnitudes of two vectors and cosine of the angle between them yes that's the dotproduct of the two vectors so if we think of fbar as the force and DZ as the displacement then this product is simply work done by the force over a small displacement and so integrating over the Contour means the total work done by the polio Vector field on gamma that's only the real part of the integral what about the imaginary part even though it screams cross product will'll use something else we'll consider the normal to DZ then angle made between the normal and F Bar is < by 2us Theta since sin Theta is just cosine of this angle we can identify this imaginary part as another dot product more precisely it should be the dotproduct of F Bar and the normal this time we think of fbar as fluid flow and Dot it with the normal to DZ which can be physically interpreted as flux which means how much fluid is going directly across DZ or basically the component of the fluid velocity normal to DZ with that in mind after summing up all these contributions the imaginary part of the integral would be the total flux of fluid across this Contour so just to recap the complex integral can be made more intuitive the real part is the work done by the field fbar and the imaginary part is the flux by the field fbar across gamma this is an amazing result because if we have the polio Vector field then work and flux are quite tangible things for example here the vector field goes across the Contour gamma from left to right at basically every point so without any calculation we know that the imaginary part is quite positive but this result has another very important consequence which is Koshi theorem proving the theorem is now just combining results we know we now suppose gamma is a closed contour and the region it encloses is D then Green's theorem says the line integral around gamma is related to the area integral of the 2D curl but the left hand side is work done along the closed Contour Next up we have Divergence Theorem which Rel reles the Divergence integral to an integral across gamma and the left hand side is flux across the closed loop gamma finally we know from a few minutes ago that the Divergence and 2 de curl of the poar vector field are both zero as long as F satisfies the Koshi reman equations so let's combine all these results together if the CR equation are satisfied everywhere in D with continuous partial derivatives then both Total work done along and total flux across gamma are zero since the complex integral can be written in terms of work and flux it will be zero this theorem is so important that I think we need to get it right let's say both gamma and D live inside a bigger set U and F is holomorphic or complex differentiable throughout this bigger set u and Gamma is any closed loop completely inside you then the integral of f around gamma is zero this is actually not precise enough and here is just a glimpse of how we make things rigorous don't be intimidated by the math jargon I just want to get a point across so bear with this bit one version of this theorem is to require you to be a Simply Connected domain essentially this means that any closed loop like this one gamma can be continuously shrunk to a single point if I remove a point here say this white dot then we can't shrink it all the way to a point so in this case U minus a point is not Simply Connected the other more General enal version only requires that U is open but gamma is what's called homologous to zero to put it more simply this means that for any point outside of you the winding number of gamma about that point is zero in both versions of the theorem we require that the curve gamma is pie wise smooth anyway the point is that the derivation is only the big picture and I have swept a lot of assumptions under the rug still it is very important to see the big picture first and care about those little details later but why is this theorem so important it feels like this trivializes complex analysis because the integral is always zero but first F needs to be holomorphic throughout the set u so if f is not holomorphic even just at the point this theorem fails in fact we are going to compute the integral of 1 / Z later and 1 / Z is not holomorphic at zero at least on the traditional complex plane so why is this important you've just told me that sometimes it doesn't work well let's say that the region where f is holomorphic does not completely cover gamma and D suppose that we integrate anticlockwise along gamma then another slightly modified Curve will give the same value for the integral why well if we reverse Direction in one of those sections then applying this theorem the integral would be zero more specifically the integrals along the different sections add up to zero and so they are negative of each other but the negative sign can be cancelled by reversing the direction we integrate along and so these Contours would give us the same integral so as long as f is holomorphic in the region between two loops and the two Loops are both anticlockwise or both clockwise the integrals remain the same which allows us to deform The Contours and very useful sometimes and like I said before we are going to deal with one of that now using the ideas we have just scene but before that I want to give thanks to this video sponsor data Camp data Camp is an online learning platform that offers more than 350 different courses for you to learn basic and intermediate python SQL and R and how to visualize data using those languages I am personally going through the introduction to R course because I didn't have the chance to learn R before and this course is very friendly to beginners you might notice that there is XP points here and this is what I really like even if you get the wrong answers it wouldn't affect your XP but you will earn less XP if you take a hint rather than being spoonfed it encourages you to actually try which is very important in learning a new skill data science is very useful in any field of work these days and you can use my link in the description box below and check out the first chapter of any data Camp course for free now back to the [Music] video in this chapter we will focus on integrating 1 / Zed around a closed loop gamma and Gamma is a circle centered at the origin with radius R and we integrate anticlockwise but before before we actually compute it it's good to have a rough idea of what we should expect this is the poar vector field for the function 1 / Z based on our previous chapters we know how to get the complex integral from this Vector field the real part is the work done by this field along our Contour however our field is perpendicular to the Contour and it happens everywhere along the Contour so we should expect the total work done to be zero what about the flux well this time the field goes from left to right so we experience positive flux and this left to right is everywhere along the Contour so we should expect the flux to be positive so without any computation at all we already know that the integral needs to be purely imaginary and the imaginary part is positive but how to calculate the exact value well here is one way to do it we will be using the direct parametrization method to use it we need to know what the parameterization fee is the most natural way to parameterize is through the argument so zero would correspond to the point on the real axis here and going from 0 to 2 pi corresponds to going around gamma once to make this a lot more explicit we need the formula of v in this case v of X is R * e to iix well actually because we are working with angles it makes a lot more sense to declare the variable Theta instead and now it is a matter of plugging stuff in we have the formula of V and also the lower and upper limits being 0 and 2 pi and just plug stuff in and use the formula here note that the denominator here is f of theta and the function f is one / Zed so we have this first part and the remaining bit is just the derivative of Fe but we can clear denominator entirely and we are just left with I in the integrant and so the integral turns out to be 2 pi I it is worth noting that the value of the integral does not depend on R even though the Contour gamma depends on R this is because even if we have a different radius f is holomorphic in this pink region that encloses the region between two Loops entirely so by Kosik theorem the two integrals are the same so in this chapter we see that the integral of 1 / Z around a circular Contour is 2 pi I and it is also nice to realize that the Contour is Traverse anticlockwise and this integral right there I would say the most important integral throughout complex analysis for the next chapter we are going to look at more integrals [Music] similarly we think of the integral of 1 / z^ 2 just like the previous case the radius R doesn't matter as long as it encircles the origin and again we'll use the work flux result to get some rough idea first this is the poar vector field of one of a z squ and let's see how it helps first let's see the work done well for the upper half of the loop we can see that the vector field generally aligns with the direction of travel and so the work done on the upper half is positive but on the lower half the vector field generally works against our Direction and so the work done on the lower half is negative and due to the up down symmetry of this Vector field the overall effect is that no work is is done a long gamma what about the flux then this time we first focus on the right half of the Contour the vector field generally points out of the loop and so the flux on the right half is positive and on the left half of the loop It generally points into the loop and so the flux here would be negative so just like before we can use the Left Right symmetry of the vector field to conclude that the overall flux across the loop should be zero so the integral turns out to be zero but what about one / z cubed of course we can consider its Poli of vector field and by symmetry this would be zero again but is there a more General way to do it consider instead of field which is a superposition of a source field which can be thought of as a copy of one / Z like what we saw before just translate it on the other side we have the opposite of a source so we call it a sync and this is a copy of negative one of Z again translated if we bring these together while doing the appropriate scaling we should get the vector field of one of a z squ how does this help well let's revert back to the source and sync separated we now try to integrate along a large closed loop enclosing both the source and sync and we'll deform this Loop which means we consider this Loop [Music] instead again the integral along this Loop will be the same as that on the original Loop because it encloses the source and syn together anticlockwise tce not too surprisingly these two circular Loops would give exact opposite values and so they cancel out each other and for the link between them the overall effect is just going back and forth and so the integrals would again cancel out each other so the integral along the original Contour would be zero and this has nothing to do with the distance between the source and the sink so throughout the process the integral along this Loop is zero and hence at the end the integral of 1 / z^ squ is zero this can actually generalize this time we put these two opposite Fields together on the right we have a 1 / Z squ field translated and on the left similarly we have a negative one of a z squ field translated and again we try to merge these two Fields together scaling appropriately and in the end we get a 1 / z cubed field and so using pretty much the same argument as before we can conclude that again the integral is zero and then using the same argument the integral of 1 / Z to ^ 4 would be 0o again and so on if you are wondering why combining the opposite fields of 1 / Z would give 1 / z^ 2 or combining opposite 1 / z^ SS would give 1/ z cubed you can pause and verify this limit over here for n larger than one these two are the opposite fields that we have been doing and this preactor here is the appropriate scaling that I was talking about in fact this limit is pretty much just the derivative of the negative powers of Z anyway in summary for gamma being a closed loop around the origin first off the integral of 1 / Z is 2 pi I which is as I said before the most important integral next we have the integral of 1 / Z the N is 0er as long as n is larger than 1 this is what we have spent this entire chapter on and if we have POS postive Powers instead then the integral is zero this is because the function will be holomorphic and we have Koshi theorem so among all the integer powers of Zed the integral is zero except for one of a z which is partly why this is so important you might see where this is going but we'll take a look at Koshi integral Formula First this time we are going to investigate this type of integral where gamma is any closed loop around a and F is any function holomorphic throughout the region enclosed by gamma calculating this integral is not too difficult if we first try to deform this Loop the thing about this integral is that F of Z is holomorphic within gamma and so the integrant is holomorphic except possibly at a so by Koshi theorem we can just shrink it very close to a and the integral remains unchanged the advantage of doing the shrinking is that now every point on this Loop has its function value very close to F of a and so the integral can be estimated by replacing the numerator as F of a the good thing here is that F of a is a constant and so it can be taken outside of the integral and what remains in the integral is a disguise of the integral of 1 / Z just translated by a and so it is 2 pi I now the approximation sign would be an equal sign when we shrink the loop further and further towards a and so this is really an equality so by a rearrangement we have established this equation the Koshi integral formula however what is so special about this formula the first thing to notice is that since we are integrating along long gamma we actually only need to know the value of f on that path and yet we are able to determine the value of f in the interior of gamma actually every point in the interior the this just demonstrates how rigid holomorphic functions actually are the other consequence of this formula relevant to what is coming next would be to differentiate it here is what happens when you try to differentiate with respect to a here I'm just differentiating the 1 / Z minus a part now repeat this stck and differentiate again I'm just differentiating the 1 / Z - a^ s part but just note that there is now a factor of two here and we can keep going and in general this is the formula for the nth derivative of f there are two messages in this more general form of kosi integral formula from a more theoretical perspective this tells us that we can differentiate any holomorphic function however many times we want from a more practical perspective this is one way to compute the derivative of f using just the value of f on gamma and now we go to the most useful theorem of complex analysis residue theorem residue theorem is a general method of computing the integral of f of Z around a closed loop now F of Z would not be fully holomorphic otherwise we know this is zero by Koshi theorem however for residue theorem to work there can only be a finite number of points where f is not holomorphic these points are usually called singularities just as we have done before we are going to deform the loop to our advantage this is the loop which might look complicated but this blue dot will track the path for us first off it tracks anticlockwise around one of the singularities then it goes to another loop and from there tracks anticlockwise around that Singularity and then repeats for another Singularity ultimately back to the original spot now the good thing here is that the integral around this triangular Loop should be zero Again by Koshi theorem and so we can just focus on those singularities but still how do we compute the integral around those singularities we have actually calculated easy examples of integrals before using integer powers of Zed so an idea would be to break down F of Zed in terms of these integer Powers if this is possible then all the terms involving negative powers of Zed except negative -1 would give zero contribution to the integral and of course all the non- negative powers of Z would give zero as well and then we are just left with the ne 1 power term and so integrating F of Zed would be 2 pi I * that1 power coefficient where gamma here is just a closed loop around a and the 2 pi I is that most important integral but can we actually Express F of Z in this series after all if that's not possible these discussions are useless but good news we can this is called Lon series and for the purposes of integration the most important term would be the coefficient labeled C minus one here and so we give it a name residue at a now technically Lon series requires some assumptions to exist if this is a where the series is centered around we need F to be holomorphic in an anulus around a but this assumption is pretty much always satisfied for our purposes anyway the most important takeaway here is that the integral of f of Z around a is 2 pi I * the residue of F at a there are many ways of denoting this but I'm going to use this notation rest sub F of a and if we go back to the integral we are working on labeling the singularities then the A1 Loop contributes 2 pi I * the residue there similar for the other singularities and so the integral of f of Z would simply be 2 pi itimes the sum of the residues at the singularities that gamma and circles but I think it is important to point out that gamma just like here needs to be traversed anticlockwise and taada this is the residue theorem but how do we actually compute those residues it turns out that a lot of the time just doing a series expansion and extracting that Nega -1 power is the most efficient method so for example if we need to find the residue of each to one/ Z at zero then from the usual power series for the exponentials we can just directly substitute one / Z there and the residue would be one because that's the coefficient of one / Z [Music] here from the famous book surely you're joking Mr Fineman one time Fineman boasted I can do by other methods any integral anybody else needs Contour integration to do so Paul puts up this tremendous damn integral he had obtained by starting out with a complex function that he knew the answer to taking out the real part of it and leaving only the complex part he had unwrapped it so it was only possible by Contour integration he was always deflating me like that he was a very smart fellow here he was talking about real integrals yet those are only possible by Contour integration now nobody actually knows which integral he is talking about but there is a nice thread on stack exchange that tries to create one anyway the idea behind is not actually difficult just using koshy's integral formula but it creates really scary looking integrals which could definitely have stumped Fineman but there can be some other real integrals that are easier to compute using complex analysis one standard example is this integral but I will skip through the details of calculation here because I want you to do it yourself to convert it to a contour integral the most Natural Choice of the integrant would be to Simply replace X by Z but it turns out that integrating cosine is usually bad in complex settings just from experience and so we use e to the i z instead and take the real part in this case however they are equal where the path Gamma One is the real line can you figure out why the imaginary part of the integral would automatically be zero to harness the power of complex analysis we first consider the finite case where the path goes from NE R to R and then close the Contour by going on a semicircular path anticlockwise from R back to R the integrant is not completely holomorphic and the singularities are precisely plus and minus I because they make the denominator zero the closed Contour encloses exactly one of those singularities namely I by residue theorem the integrals along two parts of the Contour add up to 2 pi I * the residue at I the straight line part is exactly what we want when R tends to infinity and the residue is something that can be readily calculated so we hope that this semicircular part is easy as it turns out in this specific case this goes to zero as R 10 ends to infinity and so we only need to calculate the residue here so the details to the left would be why this will tend to zero as R tends to infinity and how to calculate the residue in the first place I have considered going into more details but to be honest I don't really know how many people will watch until this point so if you're still here leave a comment basically to preserve my sanity in making a 30-minute video I have put some links in the description for the details required instead hopefully this basic idea is still fascinating and actually just the core of the whole thing if you're still watching Please Subscribe with notifications on like the video comment and share the video as well see you next time bye [Music]