2
$\begingroup$

The output of the following integration appear to produce imaginary terms, even though the parameters {a,b} have been specified to be real. My question: Is there a way to perform this integration where the imaginary "I" is absent.

Integrate[(1 + a*Abs[ze - zh])*E^(I*b*ze - a*Abs[ze - zh])*
  Cos[Pi*ze]^2*Cos[Pi*zh]^2, {ze, -2^(-1), 1/2}, {zh, (-1*1)/2, 1/2}, 
 Assumptions -> Element[{a, b}, Reals]]

Some bits of the long output:

(* (4 E^(-a - (I b)/
   2) π^4 (7 a^11 b^5 + a^12 b^5 - 24 I a^10 b^6 - 3 I a^11 b^6 - 
    12 a^9 b^7 - 44 I a^8 b^8 - 8 I a^9 b^8 - 54 a^7 b^9 - 
    6 a^8 b^9 - 12 I a^6 b^10 - 6 I a^7 b^10 - 44 a^5 b^11 - 
    8 a^6 b^11 + 12 I a^4 b^12 - 9 a^3 b^13 - 3 a^4 b^13 + 
    4 I a^2 b^14 + I a^3 b^14 + 24 I a^16 E^a + 136 I a^14 b^2 E^a + 
    312 I a^12 b^4 E^a - 7 a^11 b^5 E^a + 336 I a^10 b^6 E^a + 
    12 a^9 b^7 E^a + 156 I a^8 b^8 E^a + 54 a^7 b^9 E^a + 
    12 I a^6 b^10 E^a + 44 a^5 b^11 E^a - 12 I a^4 b^12 E^a + 
    9 a^3 b^13 E^a - 4 I a^2 b^14 E^a - 24 I a^16 E^(a + I b) - 
    136 I a^14 b^2 E^(a + I b) - 312 I a^12 b^4 E^(a + I b) - 
    7 a^11 b^5 E^(a + I b) - 336 I a^10 b^6 E^(a + I b) + 
    12 a^9 b^7 E^(a + I b) - 156 I a^8 b^8 E^(a + I b) + 
    54 a^7 b^9 E^(a + I b) - 12 I a^6 b^10 E^(a + I b) + 
    44 a^5 b^11 E^(a + I b) + 12 I a^4 b^12 E^(a + I b) + 
    9 a^3 b^13 E^(a + I b) + 4 I a^2 b^14 E^(a + I b) + 
    7 a^11 b^5 E^(I b) + a^12 b^5 E^(I b) + 24 I a^10 b^6 E^(I b) + 
    3 I a^11 b^6 E^(I b) - 12 a^9 b^7 E^(I b) + 
    44 I a^8 b^8 E^(I b) + 8 I a^9 b^8 E^(I b) - 54 a^7 b^9 E^(I b) - 
    6 a^8 b^9 E^(I b) + 12 I a^6 b^10 E^(I b) + 
    6 I a^7 b^10 E^(I b) - 44 a^5 b^11 E^(I b) - 8 a^6 b^11 E^(I b) - 
    12 I a^4 b^12 E^(I b) - 9 a^3 b^13 E^(I b) - 3 a^4 b^13 E^(I b) - 
    4 I a^2 b^14 E^(I b) - I a^3 b^14 E^(I b) - 
    140 a^11 b^3 π^2 - 20 a^12 b^3 π^2 + 
    480 I a^10 b^4 π^2 + 60 I a^11 b^4 π^2 + 
    336 a^9 b^5 π^2 + 16 a^10 b^5 π^2 + 
    624 I a^8 b^6 π^2 + 120 I a^9 b^6 π^2 + 
    948 a^7 b^7 π^2 + 108 a^8 b^7 π^2 + 
    96 I a^6 b^8 π^2 + 84 I a^7 b^8 π^2 + 
    764 a^5 b^9 π^2 + 140 a^6 b^9 π^2 - 
    264 I a^4 b^10 π^2 - 12 I a^5 b^10 π^2 + 
    152 a^3 b^11 π^2 + 56 a^4 b^11 π^2 - 
    80 I a^2 b^12 π^2 - 32 I a^3 b^12 π^2 - 
    12 a b^13 π^2 - 12 a^2 b^13 π^2 + 8 I b^14 π^2 + 
    4 I a b^14 π^2 + 512 I a^14 E^a π^2 + 
    1776 I a^12 b^2 E^a π^2 + 140 a^11 b^3 E^a π^2 + 
    2688 I a^10 b^4 E^a π^2 - 336 a^9 b^5 E^a π^2 + 
    1920 I a^8 b^6 E^a π^2 - 948 a^7 b^7 E^a π^2 + 
    800 I a^6 b^8 E^a π^2 - 764 a^5 b^9 E^a π^2 + 
    264 I a^4 b^10 E^a π^2 - 152 a^3 b^11 E^a π^2 + 
    80 I a^2 b^12 E^a π^2 + 12 a b^13 E^a π^2 - 
    8 I b^14 E^a π^2 - 512 I a^14 E^(a + I b) π^2 - 
    1776 I a^12 b^2 E^(a + I b) π^2 + 
    140 a^11 b^3 E^(a + I b) π^2 - 
    2688 I a^10 b^4 E^(a + I b) π^2 - 
    336 a^9 b^5 E^(a + I b) π^2 - 
    1920 I a^8 b^6 E^(a + I b) π^2 - 
    948 a^7 b^7 E^(a + I b) π^2 - 
    800 I a^6 b^8 E^(a + I b) π^2 - 
    764 a^5 b^9 E^(a + I b) π^2 - 
    264 I a^4 b^10 E^(a + I b) π^2 - 
    152 a^3 b^11 E^(a + I b) π^2 - 
    80 I a^2 b^12 E^(a + I b) π^2 *)
$\endgroup$
6
  • 1
    $\begingroup$ You have a term E^(I*b*ze.... This is complex valued, so the integral is complex-valued. $\endgroup$
    – bill s
    Commented Sep 6, 2015 at 2:04
  • $\begingroup$ @bill The output for this integral is documented in the literature, and has no imaginary terms despite the occurrence of the term you pointed out....so perhaps is there another way of writing the code to avoid the imaginary output, any constraints that I can specify. $\endgroup$
    – thils
    Commented Sep 6, 2015 at 2:16
  • $\begingroup$ Could be that there's some cancellations that MMA isn't resolving by default. Try messing with the Simplify functions. $\endgroup$
    – IPoiler
    Commented Sep 6, 2015 at 3:20
  • $\begingroup$ The output from your Integrate expression is a real-valued expression for a lot of real values of a and b, but not all. For example, neither a nor b can be zero. $\endgroup$
    – m_goldberg
    Commented Sep 6, 2015 at 3:34
  • $\begingroup$ Should this question be considered a duplicate of this one? $\endgroup$
    – m_goldberg
    Commented Sep 6, 2015 at 4:02

2 Answers 2

4
$\begingroup$

You can get an expression that is I-free by evaluating

Integrate[
  (1 + a*Abs[ze - zh])*E^(I*b*ze - a*Abs[ze - zh])*Cos[Pi*ze]^2*Cos[Pi*zh]^2, 
  {ze, -1/2, 1/2}, {zh, -1/2, 1/2}, 
  Assumptions -> Element[{a, b}, Reals]] // ComplexExpand // FullSimplify
 (8 E^-a π^4 (a b (b^4 - 20 b^2 π^2 + 64 π^4) (a^11 - 
    7 a^10 (-1 + E^a) + 16 a^9 π^2 - 
    4 a b^2 π^2 (b^2 - 4 π^2)^2 (3 b^2 - 4 π^2) - 
    12 a^8 (-1 + E^a) (-b^2 + 8 π^2) - 
    4 (-1 + E^a) (-3 b^2 + 4 π^2) (b^3 π - 
       4 b π^3)^2 - 
    6 a^7 (b^4 + 2 b^2 π^2 - 16 π^4) - 
    6 a^6 (-1 + E^a) (-9 b^4 - 22 b^2 π^2 + 80 π^4) - 
    4 a^5 (2 b^6 + 5 b^4 π^2 + 20 b^2 π^4 - 64 π^6) - 
    4 a^4 (-1 + E^a) (-11 b^6 - 29 b^4 π^2 - 
       116 b^2 π^4 + 256 π^6) - 
    a^3 (3 b^8 + 4 b^6 π^2 + 64 b^4 π^4 + 
       64 b^2 π^6 - 256 π^8) - 
    a^2 (-1 + E^a) (-9 b^8 - 28 b^6 π^2 - 64 b^4 π^4 - 
       448 b^2 π^6 + 768 π^8)) Cos[b/
   2] + (24 a^16 E^a + 8 a^14 E^a (17 b^2 + 64 π^2) + 
    4 a π^2 (b^2 - 16 π^2) (b^3 - 4 b π^2)^4 + 
    8 (-1 + E^a) π^2 (-b^2 + 16 π^2) (b^3 - 
       4 b π^2)^4 - 
    4 a^2 b^2 (-1 + E^a) (b - 4 π) (b + 4 π) (b^2 - 
       4 π^2)^2 (b^2 + 4 π^2) (b^4 + 16 π^4) - 
    12 a^5 b^2 (b - 4 π) (b - 2 π) π^2 (b + 
       2 π) (b + 4 π) (b^4 + 4 b^2 π^2 + 
       32 π^4) - 
    6 a^7 b^2 (b - 4 π) (b - 2 π) (b + 2 π) (b + 
       4 π) (b^4 + 6 b^2 π^2 + 32 π^4) + 
    24 a^12 E^a (13 b^4 + 74 b^2 π^2 + 192 π^4) - 
    3 a^11 (b^6 - 20 b^4 π^2 + 64 b^2 π^4) + 
    a^3 (b - 4 π) (b + 4 π) (b^3 - 4 b π^2)^2 (b^6 - 
       8 b^4 π^2 + 64 b^2 π^4 + 64 π^6) - 
    8 a^9 (b^8 - 15 b^6 π^2 - 36 b^4 π^4 + 
       320 b^2 π^6) + 
    8 a^10 (b^6 (-3 + 42 E^a) + 12 b^4 (5 + 28 E^a) π^2 + 
       64 b^2 (-3 + 16 E^a) π^4 + 2816 E^a π^6) + 
    4 a^8 (b^8 (-11 + 39 E^a) + 12 b^6 (13 + 40 E^a) π^2 + 
       192 b^4 (3 + 13 E^a) π^4 + 
       128 b^2 (-32 + 29 E^a) π^6 + 15872 E^a π^8) + 
    4 a^6 (3 b^10 (-1 + E^a) + 8 b^8 (3 + 25 E^a) π^2 + 
       96 b^6 (3 + 11 E^a) π^4 + 
       192 b^4 (13 + 21 E^a) π^6 + 
       2560 b^2 (-6 + E^a) π^8 + 24576 E^a π^10) + 
    4 a^4 (-3 b^12 (-1 + E^a) + 66 b^10 (-1 + E^a) π^2 + 
       32 b^8 (9 + 5 E^a) π^4 + 96 b^6 (-3 + 5 E^a) π^6 + 
       1536 b^4 (4 + E^a) π^8 + 
       1024 b^2 (-24 + 7 E^a) π^10 + 16384 E^a π^12)) Sin[
   b/2]))/(a b (a^2 + b^2)^2 (a^2 + (b - 2 π)^2)^2 (a^2 + 
 4 π^2)^2 (b^4 - 20 b^2 π^2 + 
 64 π^4) (a^2 + (b + 2 π)^2)^2)
$\endgroup$
3
$\begingroup$

The specific combination to use based on my comment is

FullSimplify[ExpToTrig[Integrate[(1 + a*Abs[ze - zh])*E^(I*b*ze - a*Abs[ze - zh])*
 Cos[Pi*ze]^2*Cos[Pi*zh]^2, {ze, -2^(-1), 1/2}, {zh, (-1*1)/2, 1/2}, 
 Assumptions -> Element[{a, b}, Reals]]]]

This will get you the real-valued result

(4 E^-a \[Pi]^4 (2 a b (b^4 - 20 b^2 \[Pi]^2 + 64 \[Pi]^4) (a^11 - 
    7 a^10 (-1 + E^a) + 16 a^9 \[Pi]^2 - 
    4 a b^2 \[Pi]^2 (b^2 - 4 \[Pi]^2)^2 (3 b^2 - 4 \[Pi]^2) - 
    12 a^8 (-1 + E^a) (-b^2 + 8 \[Pi]^2) - 
    4 (-1 + E^a) (-3 b^2 + 4 \[Pi]^2) (b^3 \[Pi] - 
       4 b \[Pi]^3)^2 - 
    6 a^7 (b^4 + 2 b^2 \[Pi]^2 - 16 \[Pi]^4) - 
    6 a^6 (-1 + E^a) (-9 b^4 - 22 b^2 \[Pi]^2 + 80 \[Pi]^4) - 
    4 a^5 (2 b^6 + 5 b^4 \[Pi]^2 + 20 b^2 \[Pi]^4 - 64 \[Pi]^6) - 
    4 a^4 (-1 + E^a) (-11 b^6 - 29 b^4 \[Pi]^2 - 
       116 b^2 \[Pi]^4 + 256 \[Pi]^6) - 
    a^3 (3 b^8 + 4 b^6 \[Pi]^2 + 64 b^4 \[Pi]^4 + 
       64 b^2 \[Pi]^6 - 256 \[Pi]^8) - 
    a^2 (-1 + E^a) (-9 b^8 - 28 b^6 \[Pi]^2 - 64 b^4 \[Pi]^4 - 
       448 b^2 \[Pi]^6 + 768 \[Pi]^8)) Cos[b/2] + 
 a (1 + E^a) (a^2 + 
    4 \[Pi]^2) ((a^2 + b^2)^2 (24 a^9 + 88 a^7 b^2 + 
       112 a^5 b^4 - 3 a^4 b^6 - 2 a^2 b^8 + b^10) + 
    4 (104 a^11 + 308 a^9 b^2 + 15 a^7 (32 + a) b^4 + 
       3 a^5 (108 + 11 a) b^6 + a^3 (112 + 29 a) b^8 + 
       3 a^2 b^10 - 8 b^12) \[Pi]^2 + 
    16 (184 a^9 - 12 (-9 + a) a^7 b^2 + 3 a^5 (96 + a) b^4 + 
       12 (1 - 2 a) a^3 b^6 - 17 a^2 b^8 + 22 b^10) \[Pi]^4 + 
    64 (168 a^7 - 4 a^5 (33 + 7 a) b^2 + 3 a^3 (40 + 7 a) b^4 + 
       21 a^2 b^6 - 28 b^8) \[Pi]^6 + 
    256 (20 a^2 - 17 b^2) (4 a^3 - a^2 b^2 - b^4) \[Pi]^8 + 
    4096 (4 a^3 - a^2 b^2 - b^4) \[Pi]^10) Sin[b/
   2] + (a^2 + b^2) (-1 + E^a) (a^2 + (b - 2 \[Pi])^2) (24 a^10 + 
    64 a^8 b^2 + 48 a^6 b^4 + 3 a^5 b^6 - a^2 (8 + a) b^8 + 
    4 (80 a^8 + 76 a^6 b^2 + 3 (12 - 5 a) a^4 b^4 + 
       9 a^2 (4 + a) b^6 - (4 + a) b^8) \[Pi]^2 + 
    32 (52 a^6 + 2 a^4 (14 + 3 a) b^2 - 12 a^2 (1 + a) b^4 + 
       3 (4 + a) b^6) \[Pi]^4 + 
    64 (4 a - 3 b) (4 a + 3 b) (4 a^2 + (4 + a) b^2) \[Pi]^6 + 
    1024 (4 a^2 + (4 + a) b^2) \[Pi]^8) (a^2 + (b + 
      2 \[Pi])^2) Sin[b/2]))/(a b (a^2 + b^2)^2 (a^2 + 
 4 \[Pi]^2)^2 (b^4 - 20 b^2 \[Pi]^2 + 
 64 \[Pi]^4) (a^4 + (b^2 - 4 \[Pi]^2)^2 + 
 2 a^2 (b^2 + 4 \[Pi]^2))^2)
$\endgroup$
0

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.