Re: help working with functions (follow-up)
- To: mathgroup at smc.vnet.net
- Subject: [mg60035] Re: help working with functions (follow-up)
- From: Paul Abbott <paul at physics.uwa.edu.au>
- Date: Mon, 29 Aug 2005 01:38:39 -0400 (EDT)
- Organization: The University of Western Australia
- References: <dero92$s7j$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In article <dero92$s7j$1 at smc.vnet.net>, Bob Hanlon <hanlonr at cox.net> wrote: > Amplifying on my previous response > > f1[i_,j_,n_]:= Module[{k=0}, > Nest[ > Append[#,#[[-2]]+#[[-1]]+i*j^(k++)]&, > {0,1}, n-2]]; > > f1[0,4,10] > > {0,1,1,2,3,5,8,13,21,34} > > You can also solve for the closed form > > expr=FullSimplify[a[k]/. > RSolve[{a[k]==a[k-1]+a[k-2]+i*j^(k-2),a[0]==0,a[1]==1}, a[k], k][[1]], > Element[k, Integers]] > > (2^(-k - 1)*(2*Sqrt[5]*(-(1 - Sqrt[5])^k + (1 + Sqrt[5])^k)*((j - 1)*j - 1) + > i*(5*2^(k + 1)*j^k + 2*Sqrt[5]*((1 - Sqrt[5])^k - (1 + Sqrt[5])^k)*j + > (-5 + > Sqrt[5])*(1 + Sqrt[5])^k - > (1 - Sqrt[5])^k*(5 + Sqrt[5]))))/(5*((j - 1)*j - 1)) > > Consequently, > > f2[i_,j_,n_]:=Table[(2^(-k-1)*(2*Sqrt[5]*(-(1-Sqrt[5])^k+(1+ > Sqrt[5])^k)*((j-1)*j-1)+i*(5*2^(k+1)*j^k+2*Sqrt[5]*(( > 1-Sqrt[5])^k-(1+Sqrt[5])^k)*j+(-5+Sqrt[5])*( > 1+Sqrt[5])^ > k-(1-Sqrt[ > 5])^k*(5+Sqrt[5]))))/(5*((j-1)*j-1)),{ > k,0,n-1}]//Simplify; > > Checking that f1 and f2 are equivalent > > And@@Flatten@Table[f1[i,j,n]==f2[i,j,n],{i,5},{j,5},{n,2,10}] > > True > > For i=0 the sequence is the Fibonacci sequence You can use this observation to rewrite expr as (i (-((1/2)(1 + Sqrt[5]))^k + j^k))/(-1 - j + j^2) + (1 + (i (1 + Sqrt[5] - 2j))/(2 (-1 - j + j^2))) Fibonacci[k] which is somewhat simpler, and clearly equal to Fibonacci[k] when i = 0. Cheers, Paul _______________________________________________________________________ Paul Abbott Phone: 61 8 6488 2734 School of Physics, M013 Fax: +61 8 6488 1014 The University of Western Australia (CRICOS Provider No 00126G) AUSTRALIA http://physics.uwa.edu.au/~paul