2

i am trying to integrate a real valued function. For some reason, Mathematica gives an answer in the complex domain. I'd be grateful for your answers.

Here is the integral:

Integrate[(-(Cos[b*s] - (2*Sin[b*s]*(a*D - b*C))/(a^2 + b^2))/E^(a*s))^2, {s, 1, ∞}, 
  Assumptions -> Element[s, Reals]]

Mathematica produces the following:

ConditionalExpression[1/4 
    (1/a + 1/(2 a - 2 I b) + 1/(2 a + 2 I b) + (-1 + E^(-2 a))/a + 
    (-1 + E^(-2 (a + I b)))/(2 (a + I b)) + 
    (-1 + E^(-2 a + 2 I b))/(2 a - 2 I b) - 
    (2 (b C - a D)^2 E^(-2 (a + I b)) (-2 b^2 E^(2 I b) + 
      a^2 (-1 + E^(2 I b))^2 + I a b (-1 + E^(4 I b))))/(a (a^2 + b^2)^3) + 
    (4 (b C - a D) E^(-2 a) (b Cos[2 b] + a Sin[2 b]))/(a^2 + b^2)^2), 
  Abs[Im[b]] < Re[a] && Re[a] > 0]
m_goldberg
  • 107,779
  • 16
  • 103
  • 257

1 Answers1

8

Your s lives on the ray [1,infinity). Integrate can kinda figure out s is real. Tell it about the other variables and then we'll proceed from there.

i1 = 
 Integrate[(-(Cos[b*s] - (2*Sin[b*s]*(a*d - b*c))/(a^2 + b^2))/
     E^(a*s))^2, {s, 1, \[Infinity]}, 
  Assumptions -> {Element[{b, c, d}, Reals], a > 0}]

(* Out[152]= 1/4 (1/a + 1/(2 a - 2 I b) + 1/(
   2 a + 2 I b) + (-1 + E^(-2 a))/a + (-1 + E^(-2 (a + I b)))/(
   2 (a + I b)) + (-1 + E^(-2 a + 2 I b))/(2 a - 2 I b) - (1/(
   a (a^2 + b^2)^3))
   2 (b c - a d)^2 E^(-2 (a + I b)) (-2 b^2 E^(2 I b) + 
      a^2 (-1 + E^(2 I b))^2 + I a b (-1 + E^(4 I b))) + (
   4 (b c - a d) E^(-2 a) (b Cos[2 b] + a Sin[2 b]))/(a^2 + b^2)^2) *)

ComplexExpand is good about separating real and imaginary parts under the assumption that variables are real-valued. It is not good at conciseness, so follow up with Simplify and hope for the best. Or trust that I checked this first.

Simplify[ComplexExpand[i1]]

(* Out[155]= (1/(4 a (a^2 + 
   b^2)^3))E^(-2 a) ((a^2 + b^2) (a^4 + b^4 + 4 b^2 c^2 - 8 a b c d + 
      2 a^2 (b^2 + 2 d^2)) + 
   a (a^5 + 4 b^4 c + 4 a^2 b c (b + 2 d) + 
      a b^2 (b^2 - 4 c^2 - 4 b d) + 2 a^3 (b^2 - 2 b d - 2 d^2)) Cos[
     2 b] - a (b^5 - 4 a^3 b c - 4 b^3 c^2 - 4 a b^2 c (b - 2 d) + 
      a^4 (b + 4 d) + 2 a^2 b (b^2 + 2 b d - 2 d^2)) Sin[2 b]) *)
Daniel Lichtblau
  • 58,970
  • 2
  • 101
  • 199