       Re: Iteratively determing successive values from previous

• To: mathgroup at smc.vnet.net
• Subject: [mg80405] Re: [mg80369] Iteratively determing successive values from previous
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Tue, 21 Aug 2007 05:08:22 -0400 (EDT)

```Recursion with memory:

Clear[x];

x = x1;
x[i_Integer?Positive] := x[i] = x[i - 1] + 1;

x

x1+4

Using RSolve

Clear[x];

x[i_] = a[i] /. RSolve[{a[i + 1] == a[i] + 1, a == x1}, a[i], i]

{i+x1-1}

{x, x[-5]}

{{x1 + 4}, {x1 - 6}}

Clear[x, y, s];

x = x1;
x[i_Integer?Positive] := x[i] =
x[i - 1] - s[i - 1]*2^(1 - i)*y[i - 1];
y = y1;
y[i_Integer?Positive] := y[i] =
y[i - 1] + s[i - 1]*2^(1 - i)*x[i - 1];

{x, y, x, y} // Collect[#, {x1, y1}] & // Simplify // ColumnForm

x1 - (y1*s)/2
y1 + (x1*s)/2
(-2*y1*(2*s + s) +
x1*(8 - s*s))/8
(2*x1*(2*s + s) +
y1*(8 - s*s))/8

Using the Documentation Center enter:

guide/RecurrenceAndSumFunctions

Bob Hanlon

---- ashesh <ashesh.cb at gmail.com> wrote:
> Hi,
>
> Need one help in determining the next value of a function from the
> previous values.
>
> Example:
>
> x(i+1) = x(i) + 1;
>
> If one iterates to find x(5), we should get it as (x(1) + 4), as the
> initial value is x(1), which is obtained
>
> x2 = x1+1;
> x3 = x2 + 1 = (x1+1) + 2 = x1 + 2
> x4 = x3 + 1 = (x2+1) + 1 = x2 + 2 = (x1+1) + 2 = x1 + 3
> x5 = x4 + 1 = (x3+1) + 1 = x3 + 2 = (x2+1) + 2 = x2 + 3 = x1 + 4
>
> Similary, I would like to know how to deal if there are two variable
> expressions, say
>
> x(i+1) = x(i) - (s_i) * (2^-i) * y(i)
> y(i+1) = y(i) + (s_i) *(2^-i) * x(i)
>
> for i =1, we have
>
> x_2 = x1 - s_1 (2^-1) y_1
> y_2 = y1 + s_1 (2^-1) x_1
>
> and for i = 2 it becomes
> x_3 = x1* (1 - (s_1) * (s_2) * (2^-3)) - y1* ((s_1) *  (2^-1) + (s_2)
> * (2^-2))
> y_3 = y1* (1 - (s_1) * (s_2) * (2^-3))  + x1* ((s_1) * (2^-1) + (s_2)
> * (2^-2))
>
> and so on .....
>
> I have tried to use Table, Nest, and few other functional iteration
> procedures. But, they seem to be giving the product of the terms
> rather than substituting to give the SUM of the terms in iterative
> manner.
>
> Hope some one can help me on this.
>
>

```

• Prev by Date: Re: Iteratively determing successive values from previous values....
• Next by Date: Re: Iteratively determing successive values from previous values....
• Previous by thread: Do You Know?
• Next by thread: getting data for Histogram