8

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])IExp[I*t], {t,0,2Pi}] ( output: 2IPi *)

    Integrate[(2^e/e^2 /. e->Exp[I*t])IExp[I*t], {t,0,2Pi}] ( output: IPiLog[4] *)

    Integrate[(I^e/e^2 /. e->Exp[I*t])IExp[I*t], {t,0,2Pi}] ( output: -Pi^2 *)

  • Version 2: I thought about the possible issue concerning the allowed range of x. In particular, I checked when the function x^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])IExp[I*t], {t,0,2Pi}, 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!

MarcoB
  • 67,153
  • 18
  • 91
  • 189
chaostang
  • 181
  • 2
  • 1
    For a simple version of this observation, set f[x_,assps_:{}]:=Integrate[x^Exp[I*t],{t,0,2*Pi},Assumptions->assps]. Then f[1] gives 2*Pi, but f[x] gives 0. With assumptions, f[x,x>1] gives 2*Pi, but f[x,x>=1] gives 0. With upper integration limit equal to a symbol a, the input Integrate[x^Exp[I*t],{t,0,a}] gives I*(ExpIntegralEi[Log[x]]-ExpIntegralEi[E^(I*a)*Log[x]]) which may explain why for a=2*Pi we sometimes get 0, and suggests that the problem has to do with the branch cut of ExpIntegralEi, as was probably clear to experienced people here. Version 12.3. – user293787 Jul 28 '22 at 04:16
  • At least, integration correctly works for concrete 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. – user64494 Jul 28 '22 at 05:13
  • 1
    The required formula can be derived in such a way: (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]. – user64494 Jul 28 '22 at 05:30
  • @user64494 what an interesting solution! Although this is not what I'm looking for in this particular case (the actual problems I want to tackle are much harder than the toy example in the question and don't have closed formulas), this way of thinking will definitely help me in the future! – chaostang Jul 28 '22 at 08:34
  • @user293787 aha, so the problem with branch cuts is much subtler than I imagined. Thanks for pointing that out. I guess this means Series is easier to use than Integrate in these situations. – chaostang Jul 28 '22 at 08:43
  • Dear @chaostang, for every fixed $x \neq 0$, your function does not have a branch cut as a function of $\epsilon$. You are completely right to point out that these integrals are not handled correctly by Mathematica. In my other comment, I just wanted to give an even simpler example that illustrates the problem that you found, to support your point that there is an issue here. – user293787 Jul 28 '22 at 08:57
  • This is a complex function of two variables. Why are you surprised it cannot do it? – Валерий Заподовников Aug 13 '22 at 10:09
  • @ВалерийЗаподовников I'm not sure I understand you correctly. Mathematically speaking, isn't it possible to treat $x$ as a parameter? I would hope that after imposing certain Assumptions, Mathematica would "treat $x$ as a parameter" as I do :) – chaostang Aug 14 '22 at 11:25

3 Answers3

6

Partial result, somehow suggested to my mind by Silvia's answer (started with x > 0):

Integrate[(x^e/e^2 /. e -> Exp[I*t])*I*Exp[I*t], {t, 0, 2*Pi}, 
 Assumptions -> (x > 1)]

(* 2 I π Log[x] *)

The result seems to depend on the system:

$Version
(*  "13.1.0 for Mac OS X ARM (64-bit) (June 16, 2022)"  *)
Michael E2
  • 235,386
  • 17
  • 334
  • 747
5

Edit

From the tracing log I see a one step deeper disagreement from this function:

(*
Evaluating this to load FunctionProperties`Singularities :
FunctionSingularities[Sin[1/x], x];
*)

FunctionProperties`Singularities[x^e/e^2,{e},{"ALL","LOCAN"}] (* {{{Im[x]==0,Re[x]<=0}},{},{{e==0,True}},{},{{x==0,True}}} *)

V.S.

FunctionProperties`Singularities[(64781+52253 I)^e/e^2,{e},{"ALL","LOCAN"}]
(* {{},{},{{e==0,True}},{},{}} *)

I guess, the first element of the result indicates positions of branch cuts, and the last element indicates branch points. (The 2nd hard boundaries by definition, the 3rd removable singularities and poles, the 4th essential singularities, etc.) And I guess, in the former case, maybe FunctionProperties`Singularities is not supposed to consider conditions on x.

An evidence of observation:

FunctionProperties`Singularities[Sqrt[a] + Sqrt[b], {a}, {"ALL", "LOCAN"}]
(* {{{Im[a]==0,Re[a]<=0}},{},{},{},{{a==0,True}}} *)

V.S.

FunctionProperties`Singularities[Sqrt[a] + Sqrt[b], {a, b}, {"ALL", "LOCAN"}]
(* {{{Im[a]==0,Re[a]<=0},{Im[b]==0,Re[b]<=0}},{},{},{},{{a==0,True},{b==0,True}}} *)

Regarding the explicit contour integration method, If we compare the computing process between

(* 64781 and 52253 are just two random primes for more readable tracing log. *)
Trace[Integrate[(64781 + 52253 I)^e/e^2, {e, 1, I, -1, -I, 1}], TraceInternal -> True, TraceDepth -> 10]

and

Trace[TimeConstrained[Integrate[x^e/e^2, {e, 1, I, -1, -I, 1}], 0.002], TraceInternal -> True, TraceDepth -> 10]

We can see the disagreement happens when computing the following steps:

Reduce`RootsAndPoles[(64781 + 52253 I)^e/e^2, e, {-1 - I, 1 + I}, False]
(* {{0, -2}} *)

V.S.

Reduce`RootsAndPoles[x^e/e^2, e, {-1 - I, 1 + I}, False]
(* $Failed *)

If we know for sure $0$ is a pole of multiplicity 2 of $x^e/e^2$ (Is it? -- my math knowledge is rusty, I can't confirm or disprove the claim.), we can help Integrate to overcome the difficulty:

Internal`InheritedBlock[{Reduce`RootsAndPoles}
 , Unprotect[Reduce`RootsAndPoles]
 ; Reduce`RootsAndPoles[x^e/e^2, e, {-1 - I, 1 + I}, False] := {{0, -2}}
 ; Integrate[x^e/e^2, {e, 1, I, -1, -I, 1}]
 ]
(* 2 I Pi Log[x] *)
Silvia
  • 27,556
  • 3
  • 84
  • 164
5

A different approach, assuming the residue is a twice differentiable function of x: We apply the operator $$ {d\over dx} x {d\over dx}\ \bullet $$ to $y(x) = F(x)$, where $F$ is the integral in question, and use DSolve to solve for $y(x)$:

F[x_] := Inactive[Integrate][x^e/e^2, {e, 1, I, -1, -I, 1}];

DSolve[{ Activate[ D[xy'[x] == F'[x] /. Inactive[Integrate][f_, path_] :> Inactive[Integrate][xf, path], x] ], y[1] == F[1] // Activate, y[2] == F[2] // Activate}, y[x], x]

(* {{y[x] -> 2 I π Log[x]}} *)

Michael E2
  • 235,386
  • 17
  • 334
  • 747