# Definite and indefinite integrations produce different results for same integrand

Consider a function subjected to the following assumptions:

assum =
a0 ∈ Reals && a1 ∈ Reals && a1 > a0 && a0 > 0 &&
m ∈ Integers && p ∈ Integers && m >= 0 && p >= 0;
TmpD = Sin[m*Pi*(a - a0)/(a1 - a0)]*Sin[p*Pi*(a - a0)/(a1 - a0)]/a


Integrating TmpD using a definite integral

Assuming[assum && m == p, Simplify[Integrate[TmpD, {a, a0, a1}]]]


produces

 (* 1/2 (-I π Cos[(2 a0 p π)/(a0-a1)]+Cos[(2 a0 p π)/(a0-a1)] CosIntegral[(2 a0 p π)/(a0-a1)]-Cos[(2 a0 p π)/(a0-a1)] CosIntegral[-((2 a1 p π)/(a0-a1))]-Log[a0]+Log[a1]+Sin[(2 a0 p π)/(a0-a1)] SinIntegral[(2 a0 p π)/(a0-a1)]-Sin[(2 a0 p π)/(a0-a1)] SinIntegral[(2 a1 p π)/(a0-a1)])*)


while integrating using a definite integral

Assuming[assum && m == p,
Simplify[tmp = Integrate[TmpD, a]; (tmp /. a -> a1) - (tmp /. a -> a0)]]


produces a result without the additional complex part

(* 1/2 (Cos[(2 a0 p π)/(a0-a1)] CosIntegral[-((2 a0 p π)/(a0-a1))]-Cos[(2 a0 p π)/(a0-a1)] CosIntegral[-((2 a1 p π)/(a0-a1))]-Log[a0]+Log[a1]+Sin[(2 a0 p π)/(a0-a1)] SinIntegral[(2 a0 p π)/(a0-a1)]-Sin[(2 a0 p π)/(a0-a1)] SinIntegral[(2 a1 p π)/(a0-a1)]) *)


Why are the results different?

• With Mathematica Version 8.0 I get the same result for definite and indefinite integration, both without complex part. Nov 14, 2016 at 7:15
• Those outputs were generated by version 11.0.0.0 of Mathematica. Nov 14, 2016 at 7:20
• I tried your example (Mma 11.0, Win7) and it, indeed, returned seemingly different results, unless I applied a FullSimplify[#, assum] & to it. Then the results appeared identical. Note that the use of Simplify[#, assum] & is not enough because of the special functions involved. Have fun! Nov 14, 2016 at 9:01

The results in Mathematica 11.0.1 (Windows) are the same. Try using global assumptions with $Assumptions for simplification with FullSimplify assum = a0 \[Element] Reals && a1 \[Element] Reals && a1 > a0 && a0 > 0 && m \[Element] Integers && p \[Element] Integers && m >= 0 && p >= 0; (*Make assumptions global*)$Assumptions = assum;
(*Compute*)
TmpD = Sin[m*Pi*(a - a0)/(a1 - a0)]*Sin[p*Pi*(a - a0)/(a1 - a0)]/a;
out1 = Assuming[assum && m == p,
Simplify[Integrate[TmpD, {a, a0, a1}]]];
out2 = Assuming[assum && m == p,
Simplify[
tmp = Integrate[TmpD, a]; (tmp /. a -> a1) - (tmp /. a -> a0)]];
(*Test without global assumptions*)
out1 - out2
(*Test with global assumptions*)
out1 - out2 // FullSimplify