3
$\begingroup$

I want to calculate the following integral with Mathamtica

Integrate[ E^(−2 x I) (Log[Abs[Cos[x − a]]] + Pi I/2 Sign[Cos[x − a]]), {x, 0, 2 Pi}]

where $a$ is a real number. The result should be $\pi e^{-2a \text{i}}$. However, Mathematica gives a result $0$. Then I tried to caculate it with the assumption $a \in \mathbb{R}$,

Integrate[E^(-2 x I) (Log[Abs[Cos[x-a]]] + Pi I/2 Sign[Cos[x -a]]), {x, 0, 2 Pi}, Assumptions -> Elements[a, Reals]]

It still gives a result $0$.

Finally, I defined a function

f[a_] := Integrate[ E^(−2 x I) (Log[Abs[Cos[x − a]]] + Pi I/2 Sign[Cos[x − a]]), {x, 0, 2 Pi}]

and calculate

f[2]

Now, it gives the correct answer $\pi e^{-4 i}$. What's the matter?

I'll add some remark. I'm using v13.3. This integral comes from the fourier transformation of p.v.$\frac{1}{z^2}$. Days ago, when I first calculated this integral, mma gives an answer like Domen commented. But today, it gives a result $0$. Certainly both results are wrong. As Neumann answered, a simple change of variable solves this problem, and bmf gives another way, but only when we already know mma doesn't work properly as the OP.

$\endgroup$
9
  • $\begingroup$ Which version are you using? In v13.3, I get the result ConditionalExpression[0, 2 a + π < 0 || 2 a > 5 π] which is undefined for $a=2$. Note that if you are calculating a Fourier transform, you should not be using Integrate but FourierTransform because these two do not behave the same way. $\endgroup$
    – Domen
    Commented Dec 20, 2023 at 10:02
  • $\begingroup$ @Domen I got the same result that you got in v13.2, however, f[2] evaluates! $\endgroup$
    – bmf
    Commented Dec 20, 2023 at 10:09
  • $\begingroup$ Here is a simplification for the integrand. Observe that Assuming[x \[Element] Reals && a \[Element] Reals, Log[Abs[Cos[a - x]]] == Log[Sqrt[Cos[(a - x)]^2]] // FullSimplify] yields True $\endgroup$
    – bmf
    Commented Dec 20, 2023 at 10:23
  • 2
    $\begingroup$ Looks like an bug to me. I would report this to "[email protected]" $\endgroup$ Commented Dec 20, 2023 at 10:40
  • $\begingroup$ @Domen I'm using v13.3 too. Actually, days ago, I get a similar result as yours. But today, I always get a result zero. I don't why. I will try FourierTransform. However, I want to know why Integrate doesn't work. $\endgroup$
    – gaoqiang
    Commented Dec 20, 2023 at 10:57

3 Answers 3

6
$\begingroup$

The only way I managed to make progress --- note that I did not use the analytic result of the OP

integrand = 
  E^(-2 x I) (Log[Abs[Cos[x - a]]] + Pi I/2 Sign[Cos[x - a]]);

Firstly, I hate Abs and I think Mma shares my feelings so I am going to help her out, based on the fact that

Assuming[x ∈ Reals && a ∈ Reals, 
 Log[Abs[Cos[a - x]]] == Log[Sqrt[Cos[(a - x)]^2]] // FullSimplify]

yields

True

We define

test[a_] := 
 Integrate[
  E^(-2 I x) (Log[Sqrt[Cos[a - x]^2]] + 
     1/2 I π Sign[Cos[a - x]]), {x, 0, 2 Pi}]

Subsequently we calculate

Table[test[index], {index, 0, 4}] // FullSimplify // AbsoluteTiming

{55.2884, {π, E^(-2 I) π, E^(-4 I) π, E^(-6 I) π, E^(-8 I) π}}

In order to do some experimental bootstrap

FindSequenceFunction[{π, E^(-2 I) π, E^(-4 I) π, 
   E^(-6 I) π, E^(-8 I) π}, a + 1] // FullSimplify

E^(-2 I a) π

And now we check against some higher values of a outside the pool that we used to bootstrap the answer.

Done! Now, someone give me a cookie

$\endgroup$
6
$\begingroup$

With a little assistance for Mathematica v12.2 the integral is evaluated

Integrand is 2Pi periodic, we can transform x-a->u

E^(\[Minus]2 (  a) I) Integrate[E^(\[Minus]2 u I) (Log[Abs[Cos[u]]] + Pi I/2Sign[Cos[u]]), {u, 0,2 Pi}]
(*E^(-2 I a) \[Pi]*)
$\endgroup$
4
  • $\begingroup$ (+1) an excellent observation! $\endgroup$
    – bmf
    Commented Dec 20, 2023 at 11:03
  • $\begingroup$ Perhaps you could add that Integrate`InverseIntegrate[stuff] fails in this case. This would be relevant, since Integrate`InverseIntegrate[stuff] attempts to perform the integration by various substitutions $\endgroup$
    – bmf
    Commented Dec 20, 2023 at 12:23
  • $\begingroup$ @bmf Mathematica v12.2 evaluates without any message $\endgroup$ Commented Dec 20, 2023 at 12:35
  • $\begingroup$ If you mean the command that you wrote in the answer, I agree. This command runs smoothly in v13.2 as well. All, I meant is that Integrate`InverseIntegrate[original integral] does not return a result. I mean without your observation, just trying to automate the substitutions in Mathematica directly. That's all $\endgroup$
    – bmf
    Commented Dec 20, 2023 at 12:59
3
$\begingroup$

Mathematica 13.3.1 on Windows 10 does it:

Integrate[E^(\[Minus]2 x I) (Log[RealAbs[Cos[x \[Minus] a]]] + 
Pi I/2 Sign[Cos[x \[Minus] a]]), {x, 0, 2 Pi}, 
Assumptions -> a >= 0 && a < 2*Pi] // ComplexExpand

Piecewise[{{Pi*Cos[2*a] - I*Pi*Sin[2*a], a > (3*Pi)/2 || a < Pi/2}, {(I*Cos[2*a] + 2*Pi*Cos[2*a] + 2*Arg[1 + E^((2*I)*a)]*Cos[2*a] + I*Cos[2*a]^2 - Pi*Cos[2*a]^2 + I*Cos[2*a]*Log[4] - I*Cos[2*a]^2*Log[Cos[a]^2] - I*Cos[2*a]* Log[(1 + Cos[2*a])^2 + Sin[2*a]^2] + Sin[2*a] - (2*I)*Pi*Sin[2*a] - (2*I)*Arg[1 + E^((2*I)*a)]*Sin[2*a] + Log[4]*Sin[2*a] - Log[(1 + Cos[2*a])^2 + Sin[2*a]^2]*Sin[2*a] + I*Sin[2*a]^2 - Pi*Sin[2*a]^2 - I*Log[Cos[a]^2]*Sin[2*a]^2)/4, a == (3*Pi)/2}, {(I*Cos[2*a] + 4*Pi*Cos[2*a] + 2*Arg[1 + E^((2*I)*a)]*Cos[2*a] + I*Cos[2*a]^2 + Pi*Cos[2*a]^2 + 2*Arg[Cos[a]]*Cos[2*a]^2 + I*Cos[2*a]*Log[4] - I*Cos[2*a]^2*Log[Cos[a]^2] - I*Cos[2*a]* Log[(1 + Cos[2*a])^2 + Sin[2*a]^2] + Sin[2*a] - (4*I)*Pi*Sin[2*a] - (2*I)*Arg[1 + E^((2*I)*a)]*Sin[2*a] + Log[4]*Sin[2*a] - Log[(1 + Cos[2*a])^2 + Sin[2*a]^2]*Sin[2*a] + I*Sin[2*a]^2 + Pi*Sin[2*a]^2 + 2*Arg[Cos[a]]*Sin[2*a]^2 - I*Log[Cos[a]^2]*Sin[2*a]^2)/4, a == Pi/2}}, (3*Pi*Cos[2*a] - Pi*Cos[2*a]^2 + 2*Pi*Cos[a]^2*Cos[2*a]^2 - (2*I)*Pi*Cos[a]*Cos[2*a]^2*Sin[a] - (3*I)*Pi*Sin[2*a] - Pi*Sin[2*a]^2 + 2*Pi*Cos[a]^2*Sin[2*a]^2 - (2*I)*Pi*Cos[a]*Sin[a]*Sin[2*a]^2)/4]

It's simpler to consider the exceptional cases separately, for example,

Integrate[E^(\[Minus]2 x I) (Log[RealAbs[Cos[x\[Minus]a]]]+Pi I/2 Sign[Cos[x\[Minus]a]])/.a->3*Pi/2,{x,0,2 Pi}]

-Pi

than to simplify the general case:

FullSimplify[(3*Pi*Cos[2*a]-Pi*Cos[2*a]^2+2*Pi*Cos[a]^2*Cos[2*a]^2-(2*I)*Pi*Cos[a]*Cos[2*a]^2*Sin[a]-(3*I)*Pi*Sin[2*a]-Pi*Sin[2*a]^2+2*Pi*Cos[a]^2*Sin[2*a]^2-(2*I)*Pi*Cos[a]*Sin[a]*Sin[2*a]^2)/4]

E^(-2 I a) \[Pi]

$\endgroup$
1
  • $\begingroup$ The result of Integrate[ E^(\[Minus]2 x I) (Log[RealAbs[Cos[x \[Minus] a]]] + Pi I/2 Sign[Cos[x \[Minus] a]]), {x, 0, 2 Pi}, Assumptions -> a >= -5 && a < 10] // ComplexExpand is similar. $\endgroup$
    – user64494
    Commented Dec 20, 2023 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.