MathGroup Archive 2002

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

Search the Archive

Re: Re: A faster alternative to ListIntegrate?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35756] Re: Re: A faster alternative to ListIntegrate?
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Mon, 29 Jul 2002 03:13:32 -0400 (EDT)
  • References: <ai07fp$1hh$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

It seems that compilation might be useful, at least for the trapezium rule:

    datay = Table[100Sin[x], {x, 0, 100, .001}];

    TrapeziumRule[{a_, r___, b_}, h_] :=  (a + b + 2Tr[{r}])/2   h

    TrapeziumRule[datay,.001]//Timing

        {1.37 Second,13.7681}


    TrapeziumRuleCmp =
        Compile[ {{data, _Real, 1}, h},
          #[[1]] + #[[-1]] + 2 Tr[Take[#, {2, -2}]] &[data] h/2
          ];

    TrapeziumRuleCmp[datay,.001]//Timing

        {0.44 Second,13.7681}

--
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





  • Prev by Date: RE: Re: A faster alternative to ListIntegrate?
  • Next by Date: Re: Question about Replace
  • Previous by thread: RE: Re: A faster alternative to ListIntegrate?
  • Next by thread: RE: RE: Re: A faster alternative to ListIntegrate?