I know how to define functions other than the ones that use a recurrence relation to calculate the $n$-th term of a sequence. How would such a function be constructed?
Asked
Active
Viewed 2,826 times
1
1 Answers
1
An example:
Table[Evaluate[a[n] /. RSolve[{a[n + 1] - 2 a[n] == 1, a[0] == 1}, a[n], n][[1]]], {n, 0, 10}]
(* {1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047} *)
A construct a function:
a[n + 1] - 2 a[n] == 1 -> a[n + 1] == 1 + 2 a[n] -> a[n] == 1 + 2 a[n - 1]
and then:
a[0] = 1;
a[n_] := a[n] = 1 + 2 a[n - 1]
Table[a[n], {n, 0, 10}]
(* {1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047} *)
Mariusz Iwaniuk
- 13,841
- 1
- 25
- 41
RSolveandRecurrenceTablemight be of interest. Have also a look atNestandFold. – Henrik Schumacher Oct 09 '18 at 13:35titleas: there is a functionf(x,y)wherexoryis arecurrencerelation. This means thatf(x,y)is anestedfunction, including the recurrence relation. The degree of recurrence should be known. If this clarification reflects what you have, then I can give a simple example. – Tugrul Temel Oct 09 '18 at 13:59DifferenceRoot[]. – J. M.'s missing motivation Oct 09 '18 at 15:48