       Speeding up HermiteH[Range[0,p],x]

• To: mathgroup at smc.vnet.net
• Subject: [mg72347] Speeding up HermiteH[Range[0,p],x]
• From: "erwann.rogard at gmail.com" <erwann.rogard at gmail.com>
• Date: Thu, 21 Dec 2006 05:34:40 -0500 (EST)

hi,

Looking at Out and Out it seems --unfortunately- that
HermiteH[Range[0,p],x] simply performs a map over Range[0,p] because if
the recurrence relation for hermite polynomials was used, we would
expect Out about twice smaller than Out (i think). The redefined
function, myHermiteH, which uses the recurrence relation is not
competitive for p<60. Would someone know of a way to improve speed?

thanks,

e.

In:=
ClearAll[myHermiteH]
rec=Compile[{{n,_Integer},{x,_Real},{h1,_Real},{h0,_Real}},2(x
h1-(n-1)h0)];
myHermiteH[p_,x_]:=Module[{h},Join[{h=1,h=2x},
Array[With[{n=#+1},h[n]=rec[n,x,h[n-1],h[n-2]]]&,{p-1}]]];

In:=
ar=Array[Random[]&,{2^10}];
rng=Range[0,p=10];

In:=
Timing[HermiteH[rng,#]&/@ar;]
Timing[myHermiteH[p,#]&/@ar;]
Timing[Outer[HermiteH,rng,ar];]

Out=
{0.096006 Second,Null}
Out=
{0.31602 Second,Null}
Out=
{0.080005 Second,Null}

• Prev by Date: Re: Re: A problem in mathematical logic
• Next by Date: Re: Any simple way to flatten all but the bottom level?
• Previous by thread: Re: Using Mathematica to solve Smullyan "Scheherazade" puzzle?
• Next by thread: Re: Speeding up HermiteH[Range[0,p],x]