MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Slow Integrate[] on standard integral

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71202] Slow Integrate[] on standard integral
  • From: "ben" <benjamin.friedrich at gmail.com>
  • Date: Fri, 10 Nov 2006 06:38:05 -0500 (EST)

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: animation question
  • Next by Date: Re: Easy way to 're-order' the axes in Plot3D
  • Previous by thread: Re: 2 dimension Newton Raphson
  • Next by thread: RE: Slow Integrate[] on standard integral