4

[Corrected equations and added simple example]

Can you solve a system of (loosely) coupled recurrence relations like this in Mathematica somehow?

{A[k] ==1+((n-k-2)/n) A[k+1] +(2/n) B[k+1] + (k/n) (A[0]), 
 B[k]==1+((n-k-1)/n) B[k+1] + (k/n) A[0]}

We want to solve it for $A[0]$ as a closed form function of $n$.

$A[k]$ is defined for $0 \leq k \leq n-2$ and $B[k]$ is defined for $1 \leq k \leq n-1$.

Version 8 doesn't do anything useful but I suspect I am not asking it in the right way.

As a simple example, if you set $n=3$ then you get four simulataneous equations.

A[0] == 1 + (2/3)*B[1] + (1/3)*A[1]
B[1] == 1 + (1/3)*A[0] + (1/3)*B[2]
B[2] == 1 + (2/3)*A[0]
A[1] == 1 + (2/3)*B[2] + (1/3)*A[0]

Solving for $A[0]$ gives you $33/5$ I believe. To start things off, how do you get Mathematica to do this?

Update. If you just take the second recurrence alone.

B[k]==1+((n-k-1)/n) B[k+1] + (k/n) A[0]

How can you get Mathematica to give a sensible solution for $B[k]$ in terms of $n$ and $A[0]$? It seems Rsolve ought to be able to do this. I even tried

RSolve[{B[k] == 1 + ((n - k - 1)/n) B[k + 1] + ((k)/n) (A[0]), 
  B[n - 1] == k A[0]/n}, B[k], k]

which should be identical. However this now gives an empty solution with the following warning.

RSolve::bvnul: For some branches of the general solution, the given boundary conditions lead to an empty solution.

I would like to tell Mathematica to only try to solve it for the defined range of $k$. Is that possible?

Simd
  • 1,119
  • 1
  • 7
  • 17
  • If replace A[0] with constant and solve first for B[k] then solve for A[k] and replace B[k] with previous solution it works. – swish Dec 25 '12 at 13:49
  • 1
    Please note that the second one isn't really "coupled" with the first but for a constant term A[0]. So RSolve[B[k]==1+((n-k-2)/n) B[k+1]+((k+1)/n) (k+A[0]),B[k],k] is able to cope with it. – Dr. belisarius Dec 25 '12 at 15:53
  • I get a horrible expression from RSolve[B[k]==1+((n-k-2)/n) B[k+1]+((k+1)/n) (k+A[0]),B[k],k] in terms of Gamma, DifferenceRoot, some Function and Pochhammer. Is there some way to extract the leading terms? – Simd Dec 25 '12 at 20:54
  • 1
    @lip1 If by "extract the leading terms" you mean generate the first few terms in the sequence, RecurrenceTable is what you are looking for. Unless you can set the value of n though, you get very long expressions. – 0xFE Dec 26 '12 at 03:44
  • @belisarius I updated the question to fix some problems and clarify the ranges we are interested in. – Simd Dec 27 '12 at 17:36
  • @lip1 The new details make much more sense, but I don't see necessarily why A[0]==6. When I let A[0]=6, I get that it is defined on the range you specify, but I get the same results when A[0] is any integer. – 0xFE Dec 27 '12 at 20:48
  • Where does the number 33/5 come from? – 0xFE Dec 27 '12 at 20:50
  • @user141603 If you set n =3 then you get four simultaneous equations. eq1 := A[0] = 1+(2/3)B[1]+(1/3)A[1] , eq2 := B[1] = 1 +(1/3)A[0] + (1/3)B[2] , eq3 := B[2] = 1 + (2/3)A[0] and eq4 := A[1] = 1 + (2/3)B[2] + (1/3)*A[0] . Solve for A[0]. – Simd Dec 27 '12 at 20:52
  • @lip1, have you had any progress on this? – carlosayam Jan 12 '13 at 04:24
  • The sequence of $A[0]$ for $n=2, 3, \ldots$ looks awful. Here are the first few values: $4,\frac{33}{5},\frac{180}{19},\frac{4895}{389},\frac{3324}{209},\frac{1516053}{78077},\frac{2057464}{89035},\frac{89344035}{3313213},\frac{34098720}{1100657}$, $\frac{651528436361}{18539106101},\frac{1023370836}{25941989},\frac{748806039176247}{17061288862565},\frac{3970025895220}{81923134171},\frac{190746410563815}{3588341852791},\ldots$. It's not simple. FindSequenceFunction, fwiw, fails to find any formula for these, for their numerators, or for their denominators. – whuber Mar 29 '13 at 00:48

1 Answers1

1

There may be a better way, but this solves it the same way you did. It generates all the equations and then solves them. If you only want $A_0$, use Sol[n][[1,1]].

Sol[n_] := 
Solve[Take[
Flatten[Table[{Subscript[B, k] == 
   1 + ((n - k - 1) Subscript[B, k + 1])/n + (k Subscript[A, 0])/
    n, Subscript[A, k] == 
   1 + ((n - k - 2) Subscript[A, k + 1])/n + (
    2 Subscript[B, k + 1])/n + (k Subscript[A, 0])/n}, {k, 0, 
  n - 1}]], {2, -2}]]

Edit:

Here's a graph of the first 80 values:

Graph of A_0

And the first set of differences:

Differences between consecutive A_0s

That looks somewhere between $\sqrt{x}$ and $\log{x}$.

0xFE
  • 1,038
  • 7
  • 19
  • Thanks. What I am looking for is a solution as a function of $n$. I just gave an example to make sure it was clear what was going on. I was hoping Rsolve might be able to do something useful. – Simd Dec 27 '12 at 22:27
  • @lip1 This is a function of n in the Mathematica sense. Do you mean a mathematical function, like a closed form expression? – 0xFE Dec 28 '12 at 00:21
  • Yes that is what I am looking for. – Simd Dec 28 '12 at 07:21
  • I've tried fitting some models to it and I have gotten very close, but I haven't found a closed form function. – 0xFE Dec 28 '12 at 18:21
  • user141063 Thanks! Shouldn't Rsolve be able to solve it explicitly? – Simd Dec 28 '12 at 21:13
  • I'm not sure about "should" but it doesn't seem able to. Mathematica 7 actually gives a closed form expression for the recurrence relation that only involves B[k], but it evaluates to Indeterminate for every value I've tried. – 0xFE Dec 29 '12 at 05:41