Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: Functions That Remember Values They Have Found

  • To: mathgroup at smc.vnet.net
  • Subject: [mg127655] Re: Functions That Remember Values They Have Found
  • From: Dana DeLouis <dana01 at me.com>
  • Date: Sun, 12 Aug 2012 01:48:57 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net

> Hgeom[n_] :=
>  H[n] = Sum[(1 - 0.5)^i/(1 - 0.5^i) Hgeom[n - i], {i, 1, n}]/n
> Hgeom[0] = 1;


Hi.  I see you have a solution.  If you later want to eliminate the recursive part...

fx[n_]:=((-1)^-n 2^(1/2 (-1+n) n))/QPochhammer[2,2,n]

Hgeom3[18]//Timing
{0.00296,   =
11417981541647679048466287755595961091061972992/864390930149924278258644465301081415783295060766875}


fx[18]//Timing
{0.000073,  =
11417981541647679048466287755595961091061972992/864390930149924278258644465301081415783295060766875}

%%[[-1]]==%[[-1]]
True


fx[4]//N
0.203175

= = = = = = = = = =
HTH   :>)
=E2=80=A8Dana DeLouis
Mac & Mathematica 8

To understand recursion, one must first understand recursion.
=E2=80=A8= = = = = = = = = =




On Aug 6, 4:53 am, Esteban Gonz=C3=A1lez Morales <yo8... at gmail.com> wrote:
> Hi, I was trying to create a recursive function and I read the help about it, and wrote this code
>
> Hgeom[n_] :=
>  H[n] = Sum[(1 - 0.5)^i/(1 - 0.5^i) Hgeom[n - i], {i, 1, n}]/n
> Hgeom[0] = 1;
>
> However, when I calculate Hgeom[10] it gives me the right value, and then I ask for the information about Hgeom and get that it has values calculated.
>
> Have you any idea what could have gone wrong?





  • Prev by Date: Re: VectorPlot3D
  • Next by Date: Re: VectorPlot3D
  • Previous by thread: Re: Functions That Remember Values They Have Found
  • Next by thread: Surface Smoothing