Different integration results when TrigToExp used

I am trying to do a double integral over a domain $$x \in (\theta_1,\theta_2), y \in (0,\theta_1)$$. Instead of doing a definite integral I am doing an indefinite integral and taking limits. All that is fine, but my integrand consists of trigonometric functions, so if I do that I get a complicated answer and FullSimplify doesn't seem to do much or stops the kernel after a while; possibly because I am using Macbook Air. But surprisingly I am getting an imaginary part whereas my integrand is real, and the domain over which I am integrating is also real, $$\theta_{1,2} \in (0,2\pi)$$ .

Now instead of doing the integration with trigonometric functions now I am using TrigToExp to convert everything into exponentials and then redoing everything. Then I am getting a different answer, why is it so ?

This is the integrand.

FFG2[x_, y_, t1_,
t2_] := ((x - y) Cot[(x - y)/2]/2 - 1)^2 Csc[(x - y)/
2]^2 Sin[(t1 - x)/2] Cos[(t2 - y)/2] Csc[(t1 - t2)/
2] Csc[(x - y)/2] - ((x - y) Cot[(x - y)/2]/2 -
1)^2 Csc[(x - y)/2]^2 Cot[(x - y)/2] Cot[(t1 - t2)/2] (t1 - x)/
2;


Since the expression is complicated I am taking a part of this integrand by using collect and part,(there are 4 parts, I am picking the first one)

Part[Collect[FFG2[x, y, t1, t2], Cot[_]], 1]


which is

Cot[(t1 - t2)/2]*(((-t1 + x)*Cot[(x - y)/2]*Csc[(x - y)/2]^2)/2 +
((t1 - x)*(x - y)*Cot[(x - y)/2]^2*Csc[(x - y)/2]^2)/2 +
((-t1 + x)*(x - y)^2*Cot[(x - y)/2]^3*Csc[(x - y)/2]^2)/8)


Then I integrate over y first,

Cmp1yIntP1[x_, y_, t1_, t2_] =
Integrate[PFFG2[x, y, t1, t2, 1], y,
Assumptions -> {0 < t1 < 2 \[Pi], 0 < t2 < 2 \[Pi], t1 < t2,
t1 < x < t2, 0 < y < t1}]


and put limits,

Cmp1yResP1[x_, t1_, t2_] =
Simplify[Limit[Cmp1yIntP1[x, y, t1, t2], y -> t1,
Direction -> "FromBelow"] -
Limit[Cmp1yIntP1[x, y, t1, t2], y -> 0, Direction -> "FromAbove"]]


then do indefinite integral of x,

Cmp1xyIntP1[x_, t1_, t2_] =
Integrate[Cmp1yResP1[x, t1, t2], x,
Assumptions -> {0 < t1 < 2 \[Pi], 0 < t2 < 2 \[Pi], t1 < t2,
t1 < x < t2, 0 < y < t1}]


and put limits,

ResP1[t1_, t2_] =
Limit[Cmp1xyIntP1[x, t1, t2], x -> t2, Direction -> "FromBelow"] -
Limit[Cmp1xyIntP1[x, t1, t2], x -> t1, Direction -> "FromAbove"]


Now doing the same thing as before but with TrigToExp

Cmp2yIntP1[x_, y_, t1_, t2_] =
Integrate[TrigToExp[PFFG2[x, y, t1, t2, 1]], y,
Assumptions -> {0 < t1 < 2 \[Pi], 0 < t2 < 2 \[Pi], t1 < t2,
t1 < x < t2, 0 < y < t1}];
Cmp2yResP1[x_, t1_, t2_] =
Simplify[Limit[Cmp2yIntP1[x, y, t1, t2], y -> t1,
Direction -> "FromBelow"] -
Limit[Cmp1yIntP1[x, y, t1, t2], y -> 0, Direction -> "FromAbove"]];
Cmp2xyIntP1[x_, t1_, t2_] =
Integrate[Cmp2yResP1[x, t1, t2], x,
Assumptions -> {0 < t1 < 2 \[Pi], 0 < t2 < 2 \[Pi], t1 < t2,
t1 < x < t2, 0 < y < t1}];
Res2P1[t1_, t2_] =
Limit[Cmp2xyIntP1[x, t1, t2], x -> t2, Direction -> "FromBelow"] -
Limit[Cmp2xyIntP1[x, t1, t2], x -> t1, Direction -> "FromAbove"];
Plot[{Re[ResP1[t, \[Pi]/3 + t]], Im[ResP1[t, \[Pi]/3 + t]] }, {t, 0,
4 \[Pi]/3}]
Plot[{Re[Res2P1[t, \[Pi]/3 + t]], Im[Res2P1[t, \[Pi]/3 + t]] }, {t, 0,
4 \[Pi]/3}]


So I am getting different results on plotting. Interestingly, on converting to exponentials there is no imaginary values. Any help would be great, and how to know which one is correct ?

• Intestestingly, the answer from Rubi matches with the mathematica integration when trigonometric functions are converted to exponentials. – Jaswin May 5 at 6:06
• Then I integrate over y first and put limits, then do indefinite integral of x and put limits, first without TrigToExp and then with. So I am getting different results on Any reason why you do not show the code you used for this? This will make it easier to try it. – Nasser May 5 at 6:15
• Edited the question, but is there a way to attach .nb file ? – Jaswin May 5 at 6:46