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?
FullSimplify[#, assum] &
to it. Then the results appeared identical. Note that the use ofSimplify[#, assum] &
is not enough because of the special functions involved. Have fun! $\endgroup$ – Alexei Boulbitch Nov 14 '16 at 9:01