0
$\begingroup$

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?

$\endgroup$
3
  • 1
    $\begingroup$ With Mathematica Version 8.0 I get the same result for definite and indefinite integration, both without complex part. $\endgroup$
    – Akku14
    Nov 14, 2016 at 7:15
  • $\begingroup$ Those outputs were generated by version 11.0.0.0 of Mathematica. $\endgroup$
    – Shinrei
    Nov 14, 2016 at 7:20
  • 1
    $\begingroup$ 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! $\endgroup$ Nov 14, 2016 at 9:01

1 Answer 1

0
$\begingroup$

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

enter image description here

$\endgroup$

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.