Contour Integration

Author

Eric W. Weisstein
April 7, 2006

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Calculus/ContourIntegration.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/ContourIntegration.html.

©2006 Wolfram Research, Inc. except for portions noted otherwise

Initialization

<<Utilities`Plot`

Code

diamond=R{1,I,-1,-I,1};
square=R{I+1,I-1,-I-1,-I+1,I+1};

ShowContour[l_]:=Show[Graphics[{
Line[{Re[#],Im[#]}&/@l],
PointSize[.05],Point[{0,0}]
},AspectRatio->Automatic]]

(1/z)

ComplexPlot3D[1/z,{z,-5,5}]

Integrate[1/z,{z,π(-I-1),π(I+1)}]

NIntegrate[1/z,{z,(-I-1),(I+1)}]

NIntegrate[1/z,{z,(-I-1),0,(I+1)}]

NIntegrate[1/z,{z,-I,I}]

NIntegrate[1/z,{z,-1,1},SymbolicPreprocessing->{"EvenOddSubdivision"->False}]

NIntegrate[1/z,{z,-1,1},SymbolicPreprocessing->False]

NIntegrate[1/z,{z,-I-1,I+1},SymbolicPreprocessing->False]

NIntegrate[1/z,{z,(-I-1),0,(I+1)},SymbolicPreprocessing->False]

Exp

ComplexPlot3D[Exp[z],{z,-5,5}]

Integrate[Exp[z],{z,6-I,5+I}]

N[%]

NIntegrate[Exp[z],{z,6-I,5+I}]

Log

ComplexPlot3D[Log[z],{z,-5,5}]

(∫_(-1-i)^(1+i))log(z)dz

Integrate[Log[z],{z,-1-I,1+I}]

N[%]

NIntegrate[Log[z],{z,-1-I,1+I}]

NIntegrate[Log[z],{z,-1-I,0,1+I}]

v6

NIntegrate[Log[z],{z,-1-I,1+I}]

NIntegrate[Log[z],{z,-1-I,0,1+I}]

(∫_(-1-i)^(1+i))log(z)dz

Integrate[Log[z],{z,-I,I}]

N[%]

NIntegrate[Log[z],{z,-I,I}]

NIntegrate[Log[z],{z,-I,0,I}]

v6

NIntegrate[Log[z],{z,-I,I}]

NIntegrate[Log[z],{z,-I,0,I}]

(∫_(-∞)^∞)((e^(i z))/z)dz

Plots

Plot[Evaluate[Through[{Re,Im}[Exp[I x]/x]]],{x,-10,10},PlotStyle->{Red,Blue}]

ComplexPlot3D[Exp[z]/z,{z,-2,2},PlotPoiComplexPlotLabel->HoldForm[Exp[z]/z]]//Timing

ComplexContourPlot[Exp[z]/z,{z,-2,2},ComplexPlotLabel->HoldForm[Exp[z]/z]]//Timing

Upper Half-Plane with Half-Loop Around Origin

With[{r=.1,R=1},ShowContour[{-R,-r,I r,r,R,R+I R,-R+I R,-R}]]

v4.2

(i=Integrate[Exp[I z]/z,{z,-R,-r,I r,r,R,R+I R,-R+I R,-R},Assumptions->R>r&&#]&/@{0<r<1,r==1,r>1})//Timing

With[{r=1},Integrate[Exp[I z]/z,{z,-R,-r,I r,r,R,R+I R,-R+I R,-R},Assumptions->R>r]]//Timing

v5

(i=Integrate[Exp[I z]/z,{z,-R,-r,I r,r,R,R+I R,-R+I R,-R},Assumptions->R>r&&#]&/@{0<r<1,r==1,r>1})//Timing

With[{r=1},Integrate[Exp[I z]/z,{z,-R,-r,I r,r,R,R+I R,-R+I R,-R},Assumptions->R>r]]//Timing

v5.1

(i=Integrate[Exp[I z]/z,{z,-R,-r,I r,r,R,R+I R,-R+I R,-R},Assumptions->R>r&&#]&/@{0<r<1,r==1,r>1})//Timing

With[{r=1},Integrate[Exp[I z]/z,{z,-R,-r,I r,r,R,R+I R,-R+I R,-R},Assumptions->R>r]]//Timing

Real Axis with Half-Loop Around Origin

With[{R=1,r=.1},ShowContour[{-R,-r,I r,r,R}]]

v4.0

(i=Integrate[Exp[I z]/z,{z,-∞,-r,I r,r,∞},Assumptions->#]&/@{0<r<1,r==1,r>1})//Timing

FullSimplify[i,r>0]//Timing

v4.2

(i=Integrate[Exp[I z]/z,{z,-∞,-r,I r,r,∞},Assumptions->#]&/@{0<r<1,r==1,r>1})//Timing

FullSimplify[i,r>0]//Timing

v5

(i=Integrate[Exp[I z]/z,{z,-∞,-r,I r,r,∞},Assumptions->#]&/@{0<r<1,r==1,r>1})//Timing

v5.1

(i=Integrate[Exp[I z]/z,{z,-∞,-r,I r,r,∞},Assumptions->#]&/@{0<r<1,r==1,r>1})//Timing

(i=Integrate[Exp[I z]/z,{z,-∞,-r,I r,r,∞,I ∞,-∞},Assumptions->#]&/@{0<r<1,r==1,r>1})//Timing

(i=Integrate[Exp[I z]/z,{z,-R,-r,I r,r,R,I R,-R},Assumptions->R>r&&#]&/@{0<r<1,r==1,r>1})//Timing

Factorial

With[{a=1},ComplexPlot3D[((Exp[a z])/(1+Exp[z])),{z,-5,5}]]

With[{a=2},ComplexPlot3D[((Exp[a z])/(1+Exp[z])),{z,-5,5}]]

With[{R=2π},ShowContour[{-R,R,R+2π I,-R+2π I,-R}]]

With[{a=1/2,R=5},{NIntegrate[((Exp[a z])/(1+Exp[z])),{z,-R,R,R+2π I,-R+2π I,-R}],π/Sin[a π](1-Exp[2π I a])}]//Chop

With[{a=1/3,R=2},{NIntegrate[((Exp[a z])/(1+Exp[z])),{z,-R,R,R+2π I,-R+2π I,-R}],π/Sin[a π](1-Exp[2π I a])}]//N//Chop

Subtract@@@Table[With[{a=Random[Real,{0,1},20],R=Random[Real,{0,10},20]},{NIntegrate[((Exp[a z])/(1+Exp[z])),{z,-R,R,R+2π I,-R+2π I,-R}],π/Sin[a π](1-Exp[2π I a])}],{20}]//Chop//Union

v5

(i=Integrate[((Exp[a z])/(1+Exp[z])),{z,-R,R,R+2π I,-R+2π I,-R}])//Timing

Table[With[{a=Random[Real,{0,1},20],R=Random[Real,{0,10},20]},Evaluate[i]],{20}]//Chop//Union

Limit[i,R->∞]

(i2=Integrate[((Exp[a z])/(1+Exp[z])),{z,-R,R,R+2π I,-R+2π I,-R},Assumptions->0<a<1&&R>0])//Timing

(i3=Integrate[((Exp[a z])/(1+Exp[z])),{z,-R,R,R+2π I,-R+2π I,-R},Assumptions->0<a<1])//Timing

v6

(i=Integrate[((Exp[a z])/(1+Exp[z])),{z,-R,R,R+2π I,-R+2π I,-R}])//Timing

Limit[i,R->∞]

(i2=Integrate[((Exp[a z])/(1+Exp[z])),{z,-R,R,R+2π I,-R+2π I,-R},Assumptions->0<a<1&&R>0])//Timing

(i3=Integrate[((Exp[a z])/(1+Exp[z])),{z,-R,R,R+2π I,-R+2π I,-R},Assumptions->0<a<1])//Timing

Bernoulli Numbers

Diamond

Table[((n!)/(2π I))Integrate[Evaluate[(z/(Exp[z]-1))(1/(z^(n+1)))],{z,R,I R,-R,-I R,R},Assumptions->0<R<2π],{n,2}]

%/.R->1

Integrate[(1/((-1+(E^z)) z)),z]

With[{R=2},Table[((n!)/(2π I))NIntegrate[Evaluate[(z/(Exp[z]-1))(1/(z^(n+1)))],{z,R,I R,-R,-I R,R},
WorkingPrecision->20,
MaxRecursion->10,
Method->DoubleExponential],{n,10}]
]//Chop

BernoulliB/@Range[10]//N

BernoulliB/@Range[10]

Circle with Tongue

With[{r=.1,R=1},ShowContour[{-r,r I,r I+R,R I,-R,-R I,-r I+R,-r I,-r}]
]

With[{r=.01,R=1000},Table[((n!)/(2π I))NIntegrate[Evaluate[(z/(Exp[z]-1))(1/(z^(n+1)))],{z,-r,-I r,-I r+R,-I R,-R,I R,I r+R,I r,-r},
WorkingPrecision->20,
MaxRecursion->10,
Method->DoubleExponential],{n,10}]
]//Chop

With[{r=.01,R=10000},Table[((n!)/(2π I))NIntegrate[Evaluate[(z/(Exp[z]-1))(1/(z^(n+1)))],{z,-r,-I r,-I r+R,-I R,-R,I R,I r+R,I r,-r},
WorkingPrecision->20,
MaxRecursion->10,
Method->DoubleExponential],{n,10}]
]//Chop

BesselJ

Integrate[Exp[(x/2)(t-(1/t))](t^(-n-1)),t]

(1/(2π I))Integrate[Exp[(x/2)(t-(1/t))](t^(-n-1)),{t,Sequence@@diamond}]

(1/(2π I))Integrate[Exp[(x/2)(t-(1/t))](t^(-n-1)),{t,Sequence@@square}]

ModifiedBessel

Integrate[Exp[(x/2)(t+(1/t))](t^(-n-1)),t]

(1/(2π I))Integrate[Exp[(x/2)(t+(1/t))](t^(-n-1)),{t,Sequence@@diamond}]

(1/(2π I))Integrate[Exp[(x/2)(t+(1/t))](t^(-n-1)),{t,Sequence@@square}]

LegendreP

v4.2

Integrate[(((1-2t x+(t^2)))^(-1/2))(t^(-n-1)),t]

i1=(1/(2π I))Integrate[(((1-2t x+(t^2)))^(-1/2))(t^(-n-1)),{t,Sequence@@diamond}]

Cases[i1,_AppellF1,{1,∞}]

AppellF1[-n,(1/2),(1/2),1-n,(R/(x-(Sqrt[-1+(x^2)]))),(R/(x+(Sqrt[-1+(x^2)])))]/.n->1

i2=(1/(2π I))Integrate[(((1-2t x+(t^2)))^(-1/2))(t^(-n-1)),{t,Sequence@@square}]

v5.0

Integrate[(((1-2t x+(t^2)))^(-1/2))(t^(-n-1)),t]

(1/(2π I))Integrate[(((1-2t x+(t^2)))^(-1/2))(t^(-n-1)),{t,Sequence@@diamond}]

...crash...

(1/(2π I))Integrate[(((1-2t x+(t^2)))^(-1/2))(t^(-n-1)),{t,Sequence@@square}]

...crash...

v6

Integrate[(((1-2t x+(t^2)))^(-1/2))(t^(-n-1)),t]

(1/(2π I))Integrate[(((1-2t x+(t^2)))^(-1/2))(t^(-n-1)),{t,Sequence@@diamond}]

...crash...

(1/(2π I))Integrate[(((1-2t x+(t^2)))^(-1/2))(t^(-n-1)),{t,Sequence@@square}]

...crash...

HermiteH

((n!)/(2π I))Integrate[Exp[-(t^2)+2t x](t^(-n-1)),t]

v5.1

((n!)/(2π I))Integrate[Exp[-(t^2)+2t x](t^(-n-1)),{t,Sequence@@diamond}]//Timing

((n!)/(2π I))Integrate[Exp[-(t^2)+2t x](t^(-n-1)),{t,Sequence@@square}]//Timing

LaguerreL

Integrate[((Exp[-x t/(1-t)])/((1-t)(t^(n+1)))),t]

v5.1

(1/(2π I))Integrate[((Exp[-x t/(1-t)])/((1-t)(t^(n+1)))),{t,Sequence@@diamond}]

(1/(2π I))Integrate[((Exp[-x t/(1-t)])/((1-t)(t^(n+1)))),{t,Sequence@@square}]

ChebyshevT

v5.1

(1/(4π I))Integrate[(((1-(t^2))(t^(-n-1)))/((1-2t x+(t^2)))),t]

(i1=(1/(4π I))Integrate[(((1-(t^2))(t^(-n-1)))/((1-2t x+(t^2)))),{t,Sequence@@diamond}])//Timing

(i2=(1/(4π I))Integrate[(((1-(t^2))(t^(-n-1)))/((1-2t x+(t^2)))),{t,Sequence@@square}])//Timing

i2/.R->1.

Limit[i2,R->∞]

(i2a=(1/(4π I))Integrate[(((1-(t^2))(t^(-n-1)))/((1-2t x+(t^2)))),{t,Sequence@@square},Assumptions->R>0])//Timing