MathGroup Archive 2006

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

Search the Archive

Re: Slow Integrate[] on standard integral

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71277] Re: Slow Integrate[] on standard integral
  • From: "Steve Luttrell" <steve_usenet at _removemefirst_luttrell.org.uk>
  • Date: Sun, 12 Nov 2006 06:49:03 -0500 (EST)
  • References: <ej1p98$dpp$1@smc.vnet.net>

I situations like this I evaluate the indefinite integral

Integrate[integrand, sp]

and then put in the integration limits by hand.

For your integral there are no hidden problems with doing this, but you have 
to be very careful if there are singularities (poles, branch points, etc).

Steve Luttrell
West Malvern, UK

"ben" <benjamin.friedrich at gmail.com> wrote in message 
news:ej1p98$dpp$1 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: Efficiency of repeatedly appending to a List
  • Next by Date: Re: Graphics--Need Help: How to show legends for graphics under Show Command?
  • Previous by thread: RE: Slow Integrate[] on standard integral
  • Next by thread: Re: Easy way to 're-order' the axes in Plot3D