2
$\begingroup$

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]
$\endgroup$
4
  • 3
    $\begingroup$ You've only told Mathematica that s is real. What about a, b, c? Also you should refrain from using capitalized letters as variables, as D is an internal function. $\endgroup$
    – RunnyKine
    Commented Mar 14, 2013 at 19:47
  • $\begingroup$ Also, what happens if $b \in \mathbb{R}$, what do the conditions then say? (I don't mean programmatically, which can be done using Reduce, but by hand.) $\endgroup$
    – rcollyer
    Commented Mar 14, 2013 at 19:50
  • $\begingroup$ Thank you very much for your response. $\endgroup$ Commented Mar 14, 2013 at 20:22
  • $\begingroup$ nothing changes though! $\endgroup$ Commented Mar 14, 2013 at 20:22

1 Answer 1

8
$\begingroup$

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]) *)
$\endgroup$
3
  • $\begingroup$ {Element[{b, c, d}, Reals], a > 0} why dont we just write Element{a,b,c,d}, Reals ? $\endgroup$ Commented Mar 14, 2013 at 20:24
  • $\begingroup$ That extra was just to get rid of the Conditional result: the positivity is to get convergence. $\endgroup$ Commented Mar 14, 2013 at 20:35
  • $\begingroup$ thank you so much, I've just started using mathematica, I greatly appreciate your help. $\endgroup$ Commented Mar 14, 2013 at 20:46

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.