I would like to compute the residue of $\frac{x^\epsilon}{\epsilon^2}=\frac1{\epsilon^2}e^{\epsilon\log x}=\frac1{\epsilon^2}\sum_{k=0}^\infty\frac1{k!}\epsilon^k\log^kx$ using Mathematica. A simple Laurent expansion / residue
{Normal@Series[x^e/e^2, {e,0,0}], Residue[x^e/e^2, {e,0}]}
yields
{1/e^2+Log[x]/e+Log[x]^2/2, Log[x]}
However, I can't seem to realize this operation using Integrate
. I have tried several versions, but none would work.
Version 1: Direct contour integration yields 0. But this should work, as it does for simpler functions or at specific values of
x
:Integrate[(x^e/e^2 /. e->Exp[I*t])*I*Exp[I*t], {t,0,2*Pi}] (* output: 0 *) Integrate[( 1/e /. e->Exp[I*t])*I*Exp[I*t], {t,0,2*Pi}] (* output: 2*I*Pi *) Integrate[(2^e/e^2 /. e->Exp[I*t])*I*Exp[I*t], {t,0,2*Pi}] (* output: I*Pi*Log[4] *) Integrate[(I^e/e^2 /. e->Exp[I*t])*I*Exp[I*t], {t,0,2*Pi}] (* output: -Pi^2 *)
Version 2: I thought about the possible issue concerning the allowed range of
x
. In particular, I checked when the functionx^e/e^2
is recognized as meromorphic:FunctionMeromorphic[x^e/e^2, e] (* output: True, if Im[x]!=0 && x!=0 *)
I then tried to impose these assumptions by hand, but
Integrate
wouldn't budge:Assuming[Im[x]!=0 && x!=0, Integrate[(x^e/e^2 /. e->Exp[I*t])*I*Exp[I*t], {t,0,2*Pi}]] (* output: 0 *) Integrate[(x^e/e^2 /. e->Exp[I*t])*I*Exp[I*t], {t,0,2*Pi}, Assumptions->(Im[x]!=0 && x!=0)] (* output: 0 *)
I found this powerful method that manually implements the contour integration. Although I didn't find this usage in the
Integrate
documentation and @Akku14 didn't provide an explanation, after playing with the command a little, I realized that the code in that particular example force Mathematica to integrate along the contour $1\rightarrow i\rightarrow-1\rightarrow -i\rightarrow 1$. So, I tried this too:Integrate[x^e/e^2, {e, 1, I, -1, -I, 1}]
which (after about 25 seconds) yields a lengthy conditional expression. However,
FullSimplify
shows the output is actually 0:Integrate[x^e/e^2, {e, 1, I, -1, -I, 1}] //FullSimplify (* output: 0, if Arg[x]>=0 && (Log[x]<0 || Arg[x]<=0) && Re[Log[x]]<0 *)
So now I'm completely at loss. Is there a way to make Integrate
behave as it should and always yield the correct answer? Or, could someone explain why Integrate
behaves in such a mysterious way, so that I would know when Integrate
could not be trusted?
Many thanks in advance!
f[x_,assps_:{}]:=Integrate[x^Exp[I*t],{t,0,2*Pi},Assumptions->assps]
. Thenf[1]
gives2*Pi
, butf[x]
gives0
. With assumptions,f[x,x>1]
gives2*Pi
, butf[x,x>=1]
gives0
. With upper integration limit equal to a symbola
, the inputIntegrate[x^Exp[I*t],{t,0,a}]
givesI*(ExpIntegralEi[Log[x]]-ExpIntegralEi[E^(I*a)*Log[x]])
which may explain why fora=2*Pi
we sometimes get0
, and suggests that the problem has to do with the branch cut ofExpIntegralEi
, as was probably clear to experienced people here. Version 12.3. $\endgroup$x
, e.g.Integrate[(Sqrt[2 - Sqrt[I]] + 1/Pi*I)^e/e^2 /. e -> Exp[I*t]*I*Exp[I*t], {t, 0, 2*Pi}]
results in\[Pi] Log[Sqrt[2 - (1 + I)/Sqrt[2]] + I/\[Pi]]^2
. $\endgroup$(FindSequenceFunction[ Table[Integrate[ Exp[y*e]/e^2 /. e -> Exp[I*t]*I*Exp[I*t], {t, 0, 2*Pi}], {y, 1, 10}], y]) /. y -> Log[x]
. $\endgroup$Series
is easier to use thanIntegrate
in these situations. $\endgroup$