1
$\begingroup$

I have this trigonometric integral which takes forever to evaluate $\int dx \frac{4 \left(\cos \left(p_1 x\right)-\frac{\sin \left(p_1 x\right)}{p_1 x}\right) \left(\cos \left(p_2 x\right)-\frac{\sin \left(p_2 x\right)}{p_2 x}\right) \left(\cos \left(p_3 x\right)-\frac{\sin \left(p_3 x\right)}{p_3 x}\right) \left(\cos \left(p_4 x\right)-\frac{\sin \left(p_4 x\right)}{p_4 x}\right)}{\pi x^2}$

$PrePrint = TraditionalForm
Clear["Global`*"]
Format[p[n_]] := Subscript[p, n]
s[n_Integer?Positive] := Sin[p[n]*x]
c[n_Integer?Positive] := Cos[p[n]*x]

D3 = (4*p[1] p[2] p[3] p[4]/Pi)*x^2* ((c[1] - (s[1]/(x*p[1])))/(p[1]*x)) 
    ((c[2] - (s[2]/(x*p[2])))/(p[2]*x)) ((c[3] - (s[3]/(x*p[3])))/(p[3]*x))
    (c[4] - (s[4]/(x*p[4])))/(p[4]*x)

D3 = FullSimplify[D3] // Expand 

Dcc = Integrate[D3, {x, n, Infinity}, 
  Assumptions -> p[1] > 0 && p[2] > 0 && p[3] > 0 && p[4] > 0 && n \[Element] Reals && n > 0 && 
p[1] \[Element] Reals && p[2] \[Element] Reals && p[3] \[Element] Reals &&p[4] \[Element] Reals]

Is there any way I can make this process faster? I want a symbolic answer so I suppose NIntegrate is not useful.

$\endgroup$
3
  • 1
    $\begingroup$ rez = TrigReduce[Expand[D3]], and then Integrate term by term: Integrate[#, {x, n, Infinity},.....]&/@rez. Integration finishes in about 10 min. $\endgroup$
    – Acus
    Commented Jan 29, 2021 at 15:35
  • 1
    $\begingroup$ D3 can be written more simply as D3 = 4/(Pi*x^2)*Times @@ ((c[#] - (s[#]/(x*p[#]))) & /@ Range[4]) $\endgroup$
    – Bob Hanlon
    Commented Jan 29, 2021 at 17:04
  • $\begingroup$ Thanks, @BobHanlon, That was helpful! $\endgroup$ Commented Jan 29, 2021 at 18:56

1 Answer 1

2
$\begingroup$

Here's a fairly fast computation, but I will leave to others to verify its correctness (keep in mind that Integrate usually should be checked). The result in this case is quite large.

s[n_Integer?Positive] := Sin[p[n]*x]
c[n_Integer?Positive] := Cos[p[n]*x]
D3 = (4*p[1] p[2] p[3] p[4]/Pi)* x^2*((c[1] - (s[1]/(x*p[1])))/(p[1]*x)) ((c[2] - (s[2]/(x*p[2])))/(p[2]*x)) ((c[3] - (s[3]/(x*p[3])))/(p[3]*x)) (c[4] - (s[4]/(x*p[4])))/(p[4]*x);

D3 = TrigToExp[D3] // Expand;  (** N.B. **)
    

Block[{a, c, x},
  Table[
   int[c_.*Power[E, I*a_.*x]*x^-k] = 
    c*Integrate[Exp[I*a*x]/x^k, {x, n, Infinity}, 
      Assumptions -> a ∈ Reals && n > 0],
   {k, 2, 6}]
  ] // AbsoluteTiming
(*
{25.1767,
 {c (E^(I a n)/n + I a Gamma[0, -I a n]), 
  1/4 c ((2 E^(I a n) (1 + I a n))/n^2 + 
     a^2 (2 CosIntegral[a n] - I (π - 2 SinIntegral[a n]))), 
  1/12 c (-((2 E^(I a n) (-2 + a n (-I + a n)))/n^3) + 
     a^3 (π + 2 I CosIntegral[a n] - 2 SinIntegral[a n])), 
  1/48 c ((2 E^(I a n) (6 + a n (2 I + a n (-1 - I a n))))/n^4 + 
     I a^4 (π + 2 I CosIntegral[a n] - 2 SinIntegral[a n])), 
  1/240 c ((2 E^(I a n) (24 + a n (6 I + a n (-2 + a n (-I + a n)))))/
     n^5 - a^5 (π + 2 I CosIntegral[a n] - 2 SinIntegral[a n]))}}
*)

int /@ (D3 /. Power[E, z_] :> Power[E, Factor[z]]) // 
  LeafCount // AbsoluteTiming

(*  {0.040694, 29187}  *)
$\endgroup$
3
  • $\begingroup$ Hi, Thanks for the answer! Could you please explain how does the last line work? $\endgroup$ Commented Jan 29, 2021 at 18:55
  • $\begingroup$ @annoying_noob Roughly int /@ (a + b + c) becomes int[a] + int[b] + int[c]. This is done after the replacement Power[E, z_] :> Power[E, Factor[z]] which makes sure the exponent of $e^\cdots$ has the x factored out. It has to be factored out to match the Power[..] pattern in the definition int[c_.* Power[E, I*a_.* x ] *x^-k] $\endgroup$
    – Michael E2
    Commented Jan 29, 2021 at 19:04
  • $\begingroup$ Oh Okay. I wasn't sure because I saw many terms like $\text{int}\bigg(\frac{ e^{-i \left(p_1-p_2-p_3-p_4\right) x}}{4 \pi x^2}\bigg)$ after running that line. So I wasn't sure whether it is supposed to be like that $\endgroup$ Commented Jan 29, 2021 at 19:13

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.