Re: A faster alternative to ListIntegrate?

• To: mathgroup at smc.vnet.net
• Subject: [mg35715] Re: A faster alternative to ListIntegrate?
• From: Tom Burton <tomburton at earthlink.net>
• Date: Sat, 27 Jul 2002 06:43:17 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Hello,

Below is a simple-minded implementation that delivers the factor of 10 I
previously suggested in private. It's only first order, but you could
improve it as needed easily.

Tom Burton

On 7/26/02 1:21 AM, in article ahr122\$l2v\$1 at smc.vnet.net, "Matthew Rosen"
<mrosen at cfa.harvard.edu> wrote:

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

In[2]:=
<<NumericalMath`ListIntegrate`
In[27]:=
xsec=4.0;Phi[n_]=Range[400];
In[29]:=
G1 := ListIntegrate[xsec Phi[n], 1]
In[28]:=
G1
Out[28]=
319998.
In[30]:=
Timing[Do[G1,{200}]]
Out[30]=
{7.6 Second,Null}
In[36]:=
li=Compile[{{y,_Real,1},{d,_Real,0}},
Tr[(#[[1]]+#[[2]])d/2&/@Partition[y,2,1]]
];
In[33]:=
G2:=li[xsec Phi[n],1]
In[34]:=
G2
Out[34]=
319998.
In[35]:=
Timing[Do[G2,{200}]]
Out[35]=
{0.57 Second,Null}

```

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