# Posible variable naming bug?

Bug introduced in 13.0 or earlier and persisting through 13.1 or later

First integral and second integral are the same just replacing $$\text{pb}$$ <--> $$x$$. While Mathematica is not able to evaluate the first integral, it can evaluate the second one

Integrate[Exp[I A Cos[x - pb]] Sin[x - z], {x, 0, 2 \[Pi]}]


$$\int_0^{2 \pi } \sin (x-z) e^{i A \cos (\text{pb}-x)} \, dx$$

Integrate[Exp[I A Cos[pb - x]] Sin[pb - z], {pb, 0, 2 \[Pi]}]


$$\text{ConditionalExpression}[2 i \pi J_1(A) \sin (x-z),A\in \mathbb{R}]$$

If we remove the pb variable from the first integral and change it to another name, let's say $$y$$, it is able to give us a result

Integrate[Exp[I A Cos[x - y]] Sin[x - z], {x, 0, 2 \[Pi]}]


$$\text{ConditionalExpression}[2 i \pi J_1(A) \sin (y-z),A\in \mathbb{R}]$$

If we move $$\text{pb}$$ to the sine and outside the exponential, we also get a result

Integrate[Exp[I A Cos[x - z]] Sin[x - pb], {x, 0, 2 \[Pi]}]


$$\text{ConditionalExpression}[-2 i \pi J_1(A) \sin (\text{pb}-z),A\in \mathbb{R}]$$

It seems from the integrals that the problem is something related to the $$\text{pb}$$ naming in the exponential. Probably this is not a bug and I am missing something.

Thank you.

• Occasionally, the canonical ordering of the variable names used in an expression can affect the performance of the internal algorithms. As you observed, using different variable names to change the relative ordering is a workaround. Dec 2, 2021 at 16:57
• This is not actually a bug. If one form gave an incorrect result, that would be a bug. This is simply a limitation of the technology. Jan 24, 2022 at 16:05

More of an observation: if you try the integration with all letters of the alphabet as integration variable, you only get the result for letters q and up

Table[
{i,Integrate[Exp[I A Cos[i - pb]] Sin[i - Z], {i, 0, 2 \[Pi]}]},
{i,Symbol/@Alphabet[]}
]

{{a, ConditionalExpression[(2*I)*Pi*BesselJ[1, A]*Sin[pb - Z], Element[A, Reals]]},
...
{p, ConditionalExpression[(2*I)*Pi*BesselJ[1, A]*Sin[pb - Z], Element[A, Reals]]},
{q, Integrate[E^(I*A*Cos[pb - q])*Sin[q - Z], {q, 0, 2*Pi}]},
...
{z, Integrate[E^(I*A*Cos[pb - z])*Sin[z - Z], {z, 0, 2*Pi}]}}


The same pattern appears for all capital letters (ignoring E, I and Z).

Edit As Bob Hanlon said in his comment, it depends on the ordering of the parameters: you only seem to get the closed form result, if the integration variable and the parameter inside Cos are ordered

Block[{varInt = abc,par = abC},
Print@Ordering[{varInt,par}];
Integrate[Exp[I A Cos[varInt - par]] Sin[varInt - Z], {varInt, 0, 2 \[Pi]}]
]

{1,2}
ConditionalExpression[(2*I)*Pi*BesselJ[1, A]*Sin[abC - Z], Element[A, Reals]]

Block[{varInt = abC,par = abc},
Print@Ordering[{varInt,par}];
Integrate[Exp[I A Cos[varInt - par]] Sin[varInt - Z], {varInt, 0, 2 \[Pi]}]
]

{2,1}
Integrate[E^(I*A*Cos[abc - abC])*Sin[abC - Z], {abC, 0, 2*Pi}]

• This is very interesting, thank you! Regardless, seems odd to me that the ordering will affect integral algorithms in such a way that Mathematica is not able to give an answer. Dec 3, 2021 at 9:12