Group Abstract Group Abstract

Message Boards Message Boards

0
|
4K Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Recursion without starting values

Posted 10 years ago

r[0] := r0; r[1] :=r1; r[n + 1] := ar[n] + br[n - 1]; Table[r[n + 1], {n, -1, 12}]

all I get is only...

{r0, r1, r[2], r[3], r[4], r[5], r[6], r[7],
  r[8], r[9], r[10], r[11], r[12], r[13]}

but i need r[2], r[3], r[4] ... r[13] depending on r0 and r1 for example:

r[2] = a b r0+ (a^2 + b) r1

thx for helping

POSTED BY: Harry Potter
3 Replies
Posted 10 years ago

That was exactly what I needed. Thanks. Ta! ^^

POSTED BY: Harry Potter

Hi,

what about this?

r[0] = r0; r[1] = r1; r[n_] := a r[n - 1] + b r[n - 2]; Table[r[x], {x, 0, 12}]

Cheers,

Marco

POSTED BY: Marco Thiel

Hi Harry Potter,

this is a simple difference equation which can be solved by Mathematica:

ClearAll["Global`*"]
sol = First @ RSolve[{r[n + 1] == a r[n] + b r[n - 1], r[0] == r0, r[1] == r1}, r[n], n];
r[n_, a_, b_] = Simplify[r[n] /. sol];
Table[r[n, a, b], {n, 0, 13}]

In case this is a homework problem the solution alone is by no means sufficient, you need to supply the intermediate calculations anyway. This can be done in an elegant way in analogy to the calculation of a closed form for Fiboncci numbers ("matrix form").

Regards -- Henrik

POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard