MathGroup Archive 2000

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

Search the Archive

Re: sum of recursive fn: solving for n

  • To: mathgroup at
  • Subject: [mg22174] Re: sum of recursive fn: solving for n
  • From: Daniel Lichtblau <danl at>
  • Date: Thu, 17 Feb 2000 01:24:05 -0500 (EST)
  • Organization: Wolfram Research, Inc.
  • References: <888afd$>
  • Sender: owner-wri-mathgroup at

fiona wrote:
> what am i doing wrong here?
> f[x_] := (f[x-1])*2
> f[1] =2
> Solve[Sum[f[x], {x, 1,n}] ==62, n]
> tia,
> fiona

Here is a method that does not rely on an ability to solve recurrences.

(i) Define f[n] for positive integer values n.

(ii) Define the sum of these for nonnegative n.

(iii) Use interpolation to approximate a reasonable value for noninteger
positive values

(iv) Use a root-finder to solve the equation.

f[1] = 2
f[n_Integer] /; n>1 := f[n] = 2*f[n-1]
g[0] = 0
g[n_Integer] /; n>=1 := g[n] = Sum[f[j], {j,1,n}]
g[x_Real] /; x>=0 := h[Floor[x]][x]
h[n_Integer] /; n>=0 := h[n] =
  Interpolation[Map[{#,g[#]}&, Range[Max[0,n-4],n+4]]]

Some examples:

In[73]:= FindRoot[g[x]==62, {x,1,2}]
Out[73]= {x -> 5.}

In[74]:= sol = x /. First[FindRoot[g[x]==1129143342278080, {x,1,2},
        WorkingPrecision->25, MaxIterations->100]] 
Out[74]= 49.00431413459350937126090

We check that this was a very accurate solution.

In[75]:= g[sol] - 1129143342278080
Out[75]= 0. 10

How does interpolation compare with the "actual" function 2^(x+1)-2?

In[76]:= g[sol] - 2^(sol+1)-2
Out[76]= -1.284160540929732817 10

Not too bad in this case, we are correct to around 5 places. And when
the actual solution is an integer we do alot better (because we do not
need interpolation then).

In[78]:= sol = x /. First[FindRoot[g[x]==2^51-2,  {x,1,2},
          WorkingPrecision->25, MaxIterations->100]]
Out[78]= 50.00000000000000000000000

Daniel Lichtblau
Wolfram Research

  • Prev by Date: Some more questions Part II: Mathematica
  • Next by Date: Re: Graphics and animation
  • Previous by thread: Re: sum of recursive fn: solving for n
  • Next by thread: Re: sum of recursive fn: solving for n