MathGroup Archive 2002

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

Search the Archive

Re: A faster alternative to ListIntegrate?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35721] Re: A faster alternative to ListIntegrate?
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Sat, 27 Jul 2002 06:43:30 -0400 (EDT)
  • References: <200207250846.EAA12103@smc.vnet.net> <ahr122$l2v$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Mathew,

Some possibilities

     <<NumericalMath`ListIntegrate`

    ListIntegrate[data]//Timing

        {6.59 Second,13.7681}

The following is suggested in the Help Browser entry for the package
    Integrate[
        Interpolation[data, InterpolationOrder\[Rule]1][x],
    {x,0,100}]//Timing

        {4.56 Second,13.768}

Trapezium rule with equal steps:

    #[[1]]+#[[-1]]+ 2 Tr[Take[#,{2,-2}]]&[data[[All,2]]] 0.01/2//Timing

        {0.22 Second,13.768}

Trapezium rule with possibly unequal steps

    (Drop[#1,1] - Drop[#1,-1]).(Drop[#2,-1] + Drop[#2,1])&[
      data[[All,1]], data[[All,2]]]/2//Timing

{0.83 Second,13.768}

--
Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565


"Matthew Rosen" <mrosen at cfa.harvard.edu> wrote in message
news:ahr122$l2v$1 at smc.vnet.net...
> Hi Everyone;
>  I've tracked down the slow operation of my Mathematica simulation code to
> lie in the ListIntegrate command:
>
> G[n_] := ListIntegrate[xsec Phi[n], 1]
>
> where both xsec and Phi[n] are 400 values long.
>
> Is there a way to speed up ListIntegrate via Compile or a similar
technique?
>
> Thanks in advance and best regards,
>
> Matt
> ---
> Matthew Rosen
> Harvard-Smithsonian Center for Astrophysics
> Mail Stop 59
> 60 Garden Street
> Cambridge, MA 02138
>
> e: mrosen at cfa.harvard.edu
> o: (617) 496-7614
>




  • Prev by Date: Re: A faster alternative to ListIntegrate? postscript
  • Next by Date: More weird integration issues...
  • Previous by thread: A faster alternative to ListIntegrate?
  • Next by thread: Re: A faster alternative to ListIntegrate? [2]