Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: recursion won't work for some reason


	This is a perfect problem for LinearRecurrence:

LinearRecurrence[{0,0,-1,0,0,21,0,0,69,0,0,64},{1,1,1,5,4,3,25,23,22,149
,130,110},30]

	Best,

	Harvey

-----Original Message-----
From: Bob Hanlon [mailto:hanlonr357 at gmail.com]
Sent: Wednesday, February 08, 2012 5:34 AM
To: mathgroup at smc.vnet.net
Subject: [mg124861] Re: recursion won't work for some reason

Use Set ( = ) rather than Equal ( == ) to initialize the sequence.

Clear[a, n]

a[1] = 1; a[2] = 1; a[3] = 1; a[4] = 5; a[5] = 4; a[6] = 3; 
a[7] = 25;
a[8] = 23; a[9] = 22; a[10] = 149; a[11] = 130; a[12] = 110;
a[n_Integer?Positive] :=  a[n] = 64*a[-12 + n] + 69*a[-9 + n] + 21*a[-6
+ n] - a[-3 + n]

Table[a[n], {n, 1, 30}]

{1,1,1,5,4,3,25,23,22,149,130,110,785,693,623,4389,3880,3397,23977,21115
,18684,131893,116502,102680,724705,638985,563949,3980357,3512812,3098935
}


Bob Hanlon


On Tue, Feb 7, 2012 at 4:01 AM, Roger Bagula <roger.bagula at gmail.com>
wrote:
> This recursion is translated from a FindSequenceFunction[]:
> won't work in version 8?
> Clear[a, n]
> a[1] == 1; a[2] == 1; a[3] == 1; a[4] == 5; a[5] =
== 4=
; a[6] == 3;
> a[7] == 25; a[8] == 23; a[9] == 22; a[10] == 149; =
a[11] =
== 130;
> a[12] == 110;
> a[n_] := a[n] =
>  64* a[-12 + n] + 69 *a[-9 + n] + 21 *a[-6 + n] - a[-3 + n]
> Table[a[n], {n, 1, 30}] I actually have hundreds like this that work
> with no problems...from version 5 and before.
> The FindSequenceFunction is:
> f[n_] = FindSequenceFunction[{1, 1, 1, 5, 4, 3, 25, 23, 22, 149, =
130,
>   110, 785, 693, 623, 4389, 3880, 3397, 23977, 21115, 18684, 131893,
>   116502, 102680, 724705, 638985, 563949, 3980357, 3512812, 3098935,
>   21873593, 19295871, 17024690, 120159701, 106019274, 93536946,
>   660211505, 582473085, 513900795, 3627162981, 3200166736,
>   2823410521, 19928207945, 17582033699, 15512135608, 109487029365,
>   96597344158, 85225004732, 601533119489, 530715145745,
>   468234819865}, n]
> Table[f[n], {n, 1, 30}]
> {1, 1, 1, 5, 4, 3, 25, 23, 22, 149, 130, 110, 785, 693, 623, 4389,
> 3880, 3397, 23977, 21115, 18684, 131893, 116502, 102680, 724705,
> 638985, 563949, 3980357, 3512812, 3098935}
>
> The original sequence is a polynomial expansion:
> q[x_] = (-2 + 3 x - 8 x^3 + 8 x^4)
> f[x_] = ExpandAll[x^4*q[1/x]]
> a = Table[8^(1 + Floor[n/3])*SeriesCoefficient[
>          Series[1/f[x], {x, 0, 50}], n], {n, 0, 50}]
>
> Any help that you can give will be appreciated.
>



--
Bob Hanlon




  • Prev by Date: Re: Dancing "a la Levenberg-Marquardt" to get the best Logistic Model.
  • Next by Date: Re: PDE with RecurrenceTable
  • Previous by thread: Re: recursion won't work for some reason
  • Next by thread: Re: recursion won't work for some reason