Re: sum of recursive fn: solving for n
- To: mathgroup at smc.vnet.net
- Subject: [mg22130] Re: [mg22108] sum of recursive fn: solving for n
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Wed, 16 Feb 2000 02:34:47 -0500 (EST)
- References: <200002140703.CAA12423@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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
For one thing, Sum cannot handle this symbolic summation.
In[32]:= Sum[f[x], {x,1,n}]
$RecursionLimit::reclim: Recursion depth of 256 exceeded.
$RecursionLimit::reclim: Recursion depth of 256 exceeded.
$RecursionLimit::reclim: Recursion depth of 256 exceeded.
General::stop: Further output of $RecursionLimit::reclim
will be suppressed during this calculation.
Out[32]=
Sum[2894802230932904885589274625217197696331749616641014100986439600\
> 1978282409984 Hold[f[(-253 + x) - 1]], {x, 1, n}]
One way to attack the problem is to first solve the recurrence in closed
form.
In[33]:= <<DiscreteMath`RSolve`
In[35]:= soln = RSolve[{g[x]==2*g[x-1], g[1]==2}, g[x], x]
x
Out[35]= {{g[x] -> 2 }}
Now obtain a symbolic form of the sum.
In[39]:= h[n] = Sum[g[x]/.soln[[1,1]], {x,1,n}]
n
Out[39]= 2 (-1 + 2 )
In[40]:= Solve[h[n]==62, n]
Solve::ifun: Inverse functions are being used by Solve, so some
solutions may
not be found.
Out[40]= {{n -> 5}}
Daniel Lichtblau
Wolfram Research