Mathematica Asked by annoying_noob on June 13, 2021
I have this trigonometric integral which takes forever to evaluate
$int dx frac{4 left(cos left(p_1 xright)-frac{sin left(p_1 xright)}{p_1 x}right) left(cos left(p_2 xright)-frac{sin left(p_2 xright)}{p_2 x}right) left(cos left(p_3 xright)-frac{sin left(p_3 xright)}{p_3 x}right) left(cos left(p_4 xright)-frac{sin left(p_4 xright)}{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.
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} *)
Answered by Michael E2 on June 13, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP