       Re: RecurrenceTable can't finish

• To: mathgroup at smc.vnet.net
• Subject: [mg101502] Re: RecurrenceTable can't finish
• From: dh <dh at metrohm.com>
• Date: Thu, 9 Jul 2009 01:53:23 -0400 (EDT)
• References: <h27fgt\$cpb\$1@smc.vnet.net>

```
Hi Ian,

consider your first recurrence relation:a[i] ..==a[i] .. + d[i+1] a[i+1]

If i=n: d[i+1] becomes zero and the recursion fails.

Daniel

EcoTheory wrote:

> I have a RecurrenceTable that works for all but the last element, at which it stumbles across a ComplexInfinity that does not occur when I do the final calculation myself. Here is self-contained (if not explained) code. Runs fine when the nspec for RecurrenceTable is {i,1,n-1} (as below), but gives the error when nspec is {i,1,n}. I can use the recurrence equation to calculate the last value (for n) without problems, but RecurrenceTable can't.

>

> n = 20;

> Guess = 7*10^-5;

> b[i_] := Piecewise[{{0, i == 0 || i == n}}, 3/10];

> d[i_] := Piecewise[{{0, i == 0 || i == n + 1}}, 5/10 i/n];

>

> q = RecurrenceTable[{a[i] (1 - d q1) ==

>       b[i - 1] a[i - 1] + (1 - b[i] - d[i]) a[i] + d[i + 1] a[i + 1], q1 (1 - d q1) == (1 - b - d) q1 + d a, a == Guess}, a, {i, 1, n-1}]];

>

> That the solution is right for a through a[n-1] can be confirmed with the following code.

>

> k = 10; (* Initial Population Size *)

> p0 = Table[1/k! D[x^k, {x, i}], {i, 0, n}] /. x -> 0;

> P = Table[1/(j + 1)! D[b[j] x^(j + 1), {x, i}] + 1/(j - 1)! D[d[j] x^(j - 1), {x, i}] + 1/(j)! D[(1 - (b[j] + d[j])) x^j, {x, i}], {i, 0, n}, {j, 0, n}] /. x -> 0;

> p[t_] := MatrixPower[N[P], t, p0];

> qGood = p[[2 ;; n + 1]]/(1 - p[]);

> Show[ListLinePlot[qGood], ListPlot[q]]

>

> Any suggestions?  Thanks - Ian

>

```

• Prev by Date: Re: Manipulating list
• Next by Date: Re: Selecting Rows Based on Column Values
• Previous by thread: Re: GeoDistance and transformation from WGS84 to WGS84
• Next by thread: 2dFFT & image processing