Why is there so much resemblance between the Gauss's theorem in electrostatics and Cauchy's Residue theorem?
Donāt know if I was able to clearly show the resemblance between both the theorems although they both are from different domains of applications but they sure do have many similarities anyway Iāll start answering by writing the expression for divergence in spherical and plane polar coordinate for quick reference. I know its long and also formatting is also not so good and also I have used [math]A[/math] and [math]\overrightarrow{A}[/math] interchangeably.Divergence in spherical polar coordinates[math]\dfrac{1}{r^{2}}\dfrac{\partial \left(r^{2} A_{r} \right)}{\partial r}+\dfrac {1}{rsin\theta}\dfrac{\partial (A_{\theta}sin\theta)}{\partial\theta}+\dfrac {1}{rsin\theta}\dfrac{\partial A_{\varphi}}{\partial\varphi}\tag{1}[/math]Divergence in plane polar coordinates[math]\dfrac{1}{\rho}\dfrac{\partial \left(\rho A_{\rho} \right)}{\partial\rho}+\dfrac {1}{\rho}\dfrac{\partial A_{\varphi}}{\partial\varphi}\tag{2}[/math]Discussion on Gaussā¤ Theorem in ElectrostaticsConsider a vector field [math]\overrightarrow{A}[/math] that is dependent only on radial distance from the origin. This will make the last two terms in both the divergence equations [math]0[/math].Now if I let [math]A_{r}[/math] to be an inverse square field (since we are going to discuss about electrostatics) then in (1) the [math]r^{2}[/math] multiplying the inverse square term in [math]A_{r}[/math] will cancel out and will give a constant term which leads to the divergence being identically zero everywhere. Notice that the same will happen if we choose [math]A_{\rho}[/math] of cylindrical coordinate system to be an inverse radial function.In fact in n-dimensions the form of the radial component of the radial term remains the same**. In n-dimensions if we choose [math]A_{r}[/math] to be proportional to [math]\ r^{-(n-1)}[/math] then we will get an identically divergence-free ([math]\nabla\cdot A=0[/math] ) field.The radial coordinate term in n-dimensional divergence expression will look like [math]\dfrac{1}{r^{n}}\dfrac{\partial \left(r^{n} A_{r} \right)}{\partial r}\tag{3}[/math]doing further calculations in 3D,Since [math]\nabla\cdot A=0[/math] then [math]\oint _{V}\left( \nabla \cdot A\right) dV=0[/math] where the integral is over a volume [math]V[/math] and [math]dV[/math] is the volume element.Now by using Gauss Divergence theorem the surface integral turns out to be zero because the divergence is identically zero.[math]\int_{V}\left( \nabla \cdot\overrightarrow {A}\right) dV = \oint_{\partial V}\overrightarrow{A}\cdot \overrightarrow {ds} = \tag{4}[/math]We get [math]0[/math] but by actual calculation of this surface integral we get a different result this is shown in the following section in which we calculate the surface integral.[math]\oint _{\partial V}A\cdot\overrightarrow {ds}=\oint_{\partial V}\dfrac {\widehat {r}}{r^{2}}.\overrightarrow {ds}\tag{5}[/math]The surface area of sphere in 3-dimension is [math]4\pi r^{2}[/math] hence substituting for [math]S[/math] and notice that [math]r[/math] is a constant over the surface of sphere hence it can be taken out of the differential. The [math]r^{2}[/math] and [math]\dfrac{1}{r^{2}}[/math] terms cancel each other out.[math]\oint_{\partial V}\dfrac {\widehat {r}}{r^{2}}.\overrightarrow {ds} = \oint_{\partial V} \dfrac {1}{r^{2}}d\left(4\pi r^{2}\right)\tag{6}[/math]and hence[math]\oint _{\partial V}A\cdot\overrightarrow {ds} = 4\pi \tag{7} [/math]which is not [math]0[/math] as we found in (1). We clearly have a contradiction. Only thing that can be said is the contribution [math]4\pi[/math] is completely due to the origin ([math]\overrightarrow{r}=0[/math]) as [math]\nabla\cdot A=0[/math] everywhere but not at the origin as at origin [math]r^{2}[/math] term is in the denominator and I did not include the origin in my calculation of divergence.So the divergence of the inverse square field can written down as[math]\nabla \cdot A=4\pi\delta\left(\left|\overrightarrow{r}\right|\right)\tag{8}[/math]where [math]\delta(|\overrightarrow{r}|)[/math] represents the 3-dimensional Dirac Delta function. It has units of volume inverse and hence can represent distribution of a physical quantity over a volume. It is [math]0[/math] everywhere except for the origin and its volume integral over all space is [math]1[/math] hence the divergence at origin is [math]4\pi[/math]. Now everything looks consistent. (A field having zero divergence everywhere and even at origin and also represent something in nature is not physical as that field will have no source. Thatās the way I think. Could be wrong.)Now to generalize this definition instead of having the volume integral to be [math]1[/math] have a value [math]q_{k}[/math] and make it represent a charge distribution. Let there be a total of [math]N[/math] number of charges and [math]q_{k}[/math] represents the [math]k^{th}[/math] charge present in the volume under consideration. Let the position vector of each charge [math]q_{k}[/math] be [math]\overrightarrow{r}_{k}[/math]. The net distribution function will be given as[math]\rho \left(r\right) = \sum ^{N}_{k=1}q_{k}\delta\left(\left|\overrightarrow {r}-\overrightarrow {r}_{k} \right|\right)\tag{9}[/math]If all the charges are included in the volume of integration then there will be multiple singularities at all the places where the charges are present. Which can be expressed as[math]\int _{V}\left( \nabla \cdot A\right) dV = \int _{V}\left(\sum^{N}_{k=1}q_k\delta\left(r-r_{k}\right)\right) dV = 4\pi\sum ^{N}_{k=1}q_{k}=\int_{\partial V} A.\overrightarrow{ds}\tag{10}[/math]Taking the last equation from (10) and multiplying and dividing by an arbitrary scaling factor [math]\varepsilon_{0}[/math] to be consistent with units[math]4\pi\varepsilon_{0}\sum ^{N}_{k=1}\dfrac{q_{k}}{\varepsilon_{0}}=\int_{\partial V} A.\overrightarrow{ds}\tag{11}[/math]Rearranging the equation[math]\sum ^{N}_{k=1}\dfrac{q_{k}}{\varepsilon_{0}}=\int_{\partial V} \dfrac{\overrightarrow{A}}{4\pi\varepsilon_{0}}.\overrightarrow{ds}\tag{12}[/math]Defining [math]\dfrac{\overrightarrow{A}}{4\pi\varepsilon_{0}}[/math] as [math]\overrightarrow{E}[/math] naming it the electric field as this quantity has the same dimensions as electric field. So the final result is[math]\sum ^{N}_{k=1}\dfrac{q_{k}}{\varepsilon_{0}}=\int_{\partial V} \overrightarrow {E}.\overrightarrow{ds}=\Phi_{E}\tag{13}[/math][math]\Phi_{E} = Electric\ Field\ Flux\tag{14}[/math]Gauss Law in Electrostatics is derived! The electric flux passing through some surface [math]S[/math] is [math]\dfrac{Q}{\varepsilon_{0}}[/math] where [math]Q[/math] is [math]\sum^{N}_{k=1} q_{k}[/math]. This result is possible only because of the singularity that we encountered before!Discussion on the Residue Theorem in Complex AnalysisWe will start by integrating the function [math]\ f(z) = z^{n}[/math] over two closed contours (considering both to be circles of radius [math]r[/math] ).[math]C_{1}[/math] not having origin inside the closed contour[math]C_{2}[/math] having the origin inside the closed contourfor integral on [math]C_{1}[/math]when no poles of the function (here [math]z = [/math] when [math]n0[/math]) is inside the region of integration of any analytic function then[math]\oint_{C_{1}} {f(z)} dz = \ [/math][math] C1: \ not\ including\ any\ poles\ inside\ the\ countour\ of\ integration[/math]Hence[math]\oint_{C_{1}} {z^{n}} dz = \ \forall \ n\in \mathbb{R}\tag{14}[/math]for integral on [math]C_{2}[/math]when [math]n \neq -1[/math][math]\oint_{C2} z^{n} dz = \int_{0}^{2\pi} {{(re^{i\theta})}^n} \ i re^{i\theta} d\theta =\dfrac{i r^{n+1} e^{i(n+1)\theta}}{i(n+1)} |^{2\pi}_{0}= \tag{15}[/math]when [math]n = -1[/math][math]\oint_{C2} z^{n} dz = \int_{0}^{2\pi} \dfrac{ire^{i\theta}d\theta}{re^{i\theta}}=\int_{0}^{2\pi} id\theta = 2\pi i \tag{16}[/math]Just as in the electrostatic calculations here also because of a singularity the integral has a non-zero value where without singularity it had to be [math]0[/math]. And the singularity is of the exact same type! (More on this in the last section of this answer). Notice how the [math]i[/math] term came to be the coefficient of [math]2\pi[/math] it is because of the imaginary part of the function [math]ln(z)[/math].Now any analytic function [math]\ f(z) [/math] inside its annulus of convergence can be expanded in a power series called the Laurent Series (basically it is just Taylor Series with negative powers also present in the expansion). It can be represented as[math]f(z) = \sum ^{\infty }_{-\infty }a_{k}\left( z-z_{0}\right)^{k}\tag{17}[/math]when we put this expression of [math]f(z)[/math] in [math]\oint f(z)dz[/math] we get[math]\oint {\sum^{\infty }_{-\infty }a_{k}\left( z-z_{0}\right)^{k}}dz\tag{18}[/math]Now all the terms except for the [math]k=-1[/math] term will be zero after the integral. What remains is the term [math]a_{-1}[/math]. This [math]a_{-1}[/math] is called the residue of the function at the pole on which it is calculated (the name residue is correctly given). This residue is equivalent to the charge of particles we defined in the electrostatic calculations.The above calculation leads us to the following result[math]\oint f(z) dz = \oint \dfrac{a_{-1}}{z-z_{o}}dz\tag{19}[/math][math]\oint f(z) dz = 2\pi i \ a_{-1}\tag{20}[/math]which is the residue theorem. In general if we have poles (say [math]P[/math] poles) at points inside the closed contour of integration then the following result is true[math]\oint f(z) dz = 2\pi i \sum ^{P}_{1}Res(f(z),a_{k})\tag{21}[/math]I have just summed up all the residues inside the contour. This is the residue theorem in its generality.Discussion on similarities and differencesOne can notice that the way of derivation is almost similar and hence is result. The crux of both the theorem are singularities. Both the results say that sum all the residues ( charges in the electrostatic case ) and multiply it to a certain constant factor to get the result.Certainly one thing that possibly could bug someone is the fact that both the constants are different. [math]4\pi[/math] in the case of electrostatics and [math]2\pi i[/math] in the case of Residue Theorem. The factor of [math]i[/math] could be easily explained because of the way it appeared but what decides the factor multiplying it. What decides what value should it be? The answer is simple. The dimension of the problem was the only thing that was different in both the problem calculations. It was 3D in the case of electrostatics but 2D in the case of Residue Theorem as the complex plane is 2-dimensional. That is actually the reason for the difference!I donāt know how to increase the dimensions of the complex plane there might be some way of extending it but I am not aware of it. So I will vary the dimensions in the electrostatics problem (which can easily be done).I said before that both the singularities are of the exact same type. What I meant there was that the integral over a singular point in both the cases did not vanish only for a term of a particular power for a given number of dimensions of space which were [math]\dfrac{1}{r^{2}}[/math] in electrostatics and [math]\dfrac{1}{z-z_{0}}[/math] in the residue case. If instead I would have solved the electrostatics case in 2-dimensions [math]\dfrac{1}{r}[/math] would had been that term as a fact I would have got the same factor of [math]2\pi[/math] as the constant instead of [math]4\pi[/math].Now the next thing that could be possibly be asked is how is the constant determined? Is there a expression that this constant that governs this? Well, if one look at the derivation of Gauss Theorem above one could easily show what is the equation that these coefficients depend on. From equation (3) we can say the number we get i.e. [math]4\pi[/math] is the same as coefficient of [math]r^{2}[/math] in the formula for surface area of sphere in 3-dimensions. So the question boils down to the finding the surface area of sphere in n-dimension. Which is[math]A(r;N)=2\cdot\dfrac{(\sqrt{\pi})^{N}}{\Gamma \left(\dfrac{N}{2}\right)}r^{N-1}\tag{22}[/math]where [math]\Gamma(z)[/math] is the gamma function.(The proof has been left as an exercise for the reader. haha. :P)Hence the number that shows up in n-dimensions would be:[math]2\dfrac{(\sqrt{\pi})^{N}}{\Gamma \left(\dfrac{N}{2}\right)}\tag{23}[/math]As mentioned by Prabhat in the comment section in equation (3) I have used the formula for surface area of a sphere to carry out the integration process which misleads many to think that the results that we got are specific to volume of integration being spherical. But thatās not true. In fact by using any closed volume would have got us the same result. We can use the concept of solid angle and say using the fact that every 3D volume subtends a solid angle of [math]4\pi[/math] radians at any point inside the volume. The way solid angle defined is [math]d\Omega=\dfrac{dS}{r^{2}}[/math]. Rearrange the equation to make [math]dS[/math] the subject. Substituting [math]dS=r^{2}d\Omega[/math] in equation (3) instead of directly putting in the formula of surface area of sphere. The steps would have been as follows:[math]\oint_{\partial V}\dfrac {\widehat {r}}{r^{2}}.\overrightarrow {dS} = \oint_{\partial V} \dfrac {dS}{r^{2}}\tag{24} [/math]which leads to[math]\oint_{\partial V} \dfrac {dS}{r^{2}} = \oint_{\partial V} \dfrac {r^{2}d\Omega}{r^{2}} = \oint_{\partial V}d\Omega = 4\pi \tag{25}[/math]The same result is achieved and hence the result is independent of the shape of the volume. So volume can have any shape and hence we are able to deform the volume in a continuous manner. Integral over any complicated volume will be same as the integral over a sphere (which is easy to do) and hence I have used sphere in the calculation.In complex analysis a theorem known as continuous deformation theorem or deformation invariance theorem (I donāt remember the exact name) says that:āIf we have a function āfā¤ (analytic) in a domain D containing two loops in the complex plane say, [math]\Gamma_{1}[/math] and [math]\Gamma_{2}[/math] and if these loops can be continuously deformed into one another in D, then integral of āfā¤ over [math]\Gamma_{1}[/math] and [math]\Gamma_{2}[/math] are equal. That is [math]\oint_{\Gamma_{1}}f(z)dz=\oint_{\Gamma_{2}}f(z)dz[/math].āThis is the reason all closed contour integrals about any arbitrary closed contour [math]\Gamma[/math] in complex analysis can be reduced to just calculation of the integral around circles. Same can be said about the electrostatic case just in this case instead of circles it will be spheres. Any arbitrary volume (here in 3D) can be continuously deformed into spheres (of any radius, only thing to make sure is to not take the singularity out of the volume (or charge in electrostatics) ). And that is what Gauss law actually states āto use any surface around the chargeā. Again it is a similarity! This can be considered as the counterpart of deformation invariance theorem from complex analysis and could be called as deformation invariance theorem in electrostatics.In n-dimensions solid angle can be defined as [math]d\Omega_{n}=\dfrac{dS_{n}}{r^{n-1}}[/math] which can be used to make general arguments. Hence equation (23) becomes the solid angle subtended at any point inside any closed n-dimensional volume.I guess this will be it for now. Iāll edit if something I stated is wrong or incomplete or any such case.** Though at present I donāt donāt know whether the radial part of divergence does indeed generalize in higher dimensions the way stated in (3) Itāll be a surprising to me if it doesnāt. Anyways if it doesnāt then the generalization to n-dimensions part can be ignored. Added Later: Developed an elementary proof but it requires tensor algebra (actually just the divergence expression for vectors), will add if requested.