RE: Slow Integrate[] on standard integral

• To: mathgroup at smc.vnet.net
• Subject: [mg71246] RE: [mg71202] Slow Integrate[] on standard integral
• From: "David Park" <djmp at earthlink.net>
• Date: Sat, 11 Nov 2006 03:39:24 -0500 (EST)

```integrand = Cos[sp*\[Psi]0] + (1/2)*\[Epsilon]*\[Psi]1im*
Cos[sp*\[Lambda] + t*\[Mu] - sp*\[Psi]0] -
(1/2)*\[Epsilon]*\[Psi]1im*Cos[sp*\[Lambda] + t*\[Mu] + sp*\[Psi]0] +
(1/2)*\[Epsilon]*\[Psi]1re*Sin[sp*\[Lambda] + t*\[Mu] - sp*\[Psi]0] -
(1/2)*\[Epsilon]*\[Psi]1re*Sin[sp*\[Lambda] + t*\[Mu] + sp*\[Psi]0];

Integrate[#, {sp, 0, s}] & /@ integrand

Works quickly.

David Park

From: ben [mailto:benjamin.friedrich at gmail.com]
To: mathgroup at smc.vnet.net

Dear group

I am experiencing extremly slow performance of Integrate[]
although the integrand is just a sum of sines and cosines

\!\(integrand =
Cos[sp\ \[Psi]0] +
1\/2\ \[Epsilon]\ \[Psi]1im\ Cos[
sp\ \[Lambda] + t\ \[Mu] - sp\ \[Psi]0] -
1\/2\ \[Epsilon]\ \[Psi]1im\ Cos[
sp\ \[Lambda] + t\ \[Mu] + sp\ \[Psi]0] +
1\/2\ \[Epsilon]\ \[Psi]1re\ Sin[
sp\ \[Lambda] + t\ \[Mu] - sp\ \[Psi]0] -
1\/2\ \[Epsilon]\ \[Psi]1re\ Sin[
sp\ \[Lambda] + t\ \[Mu] + sp\ \[Psi]0]\)

Developer`ClearCache["Symbolic"]
(Integrate[integrand, {sp, 0, s}] // Timing)[[1]]

Of course I can write my own integrate

(* Linearity of Integral *)

In[7]:=
myint[a_+b_,{x_,x0_,x1_}]:=myint[a,{x,x0,x1}]+myint[b,{x,x0,x1}];

In[8]:=
myint[c_ exp_,{x_,x0_,x1_}]:=c myint[exp,{x,x0,x1}]/;FreeQ[c,x];

(* Integration of Trigonemetric Functions *)

In[9]:=
myint[Sin[a_ x_+ b_:0],{x_,x0_,x1_}]:=-1/a (Cos[a x1+b]-Cos[a x0+b]);

In[29]:=
myint[Cos[a_ x_+ b_:0],{x_,x0_,x1_}]:=1/a (Sin[a x1+b]-Sin[a x0+b]);

In[71]:=
Developer`ClearCache["Symbolic"]
(myint[integrand,{sp,0,s}]//Timing)[[1]]

Out[72]=
0. Second

but I doubt this is the way to resolve such matters.
How would I have to help Integrate[] to speed things
up?

Thanks
Bem

```

• Prev by Date: Re: Typo in DedekindEta function definition?
• Next by Date: Re: 2 dimension Newton Raphson
• Previous by thread: Slow Integrate[] on standard integral
• Next by thread: Re: Slow Integrate[] on standard integral