Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

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[6] and Out[8] 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[6] about twice smaller than Out[8] (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[1]:=
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[0]=1,h[1]=2x},
Array[With[{n=#+1},h[n]=rec[n,x,h[n-1],h[n-2]]]&,{p-1}]]];

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

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

Out[6]=
{0.096006 Second,Null}
Out[7]=
{0.31602 Second,Null}
Out[8]=
{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]