# Finding n-th term of a sequence of functions

Lets say, I have the following series of functions,

$f_1=a+1$
$f_2=a^2+2a+1$
$f_3=a^3+3a^2+3a+1$
Assume that $f_4, f_5,$ and $f_6$ are also known. However $f_n$ is not known as a function of $n$.

From $f_1 ...f_6$, is it possible to reverse engineer the formula for $f_n$ using Mathematica?

For the sample sequence given above, I should get, $f_n=(a+1)^n$.

Is such a feature available in Mathematica? If so, can you provide links to the relevant documentation.

• Take a look at FindSequenceFunction – Dr. belisarius May 6 '13 at 23:35

There are many ways to proceed, but the most straightforward is FindSequenceFunction, moreover we can use as well FindLinearRecurrence with RSolve or even Factor since it can provide obvious hints to make adequate conclusions.

## Factor

Factor @ {a + 1, a^2 + 2 a + 1, a^3 + 3 a^2 + 3 a + 1}

{1 + a, (1 + a)^2, (1 + a)^3}


Now we can simply conclude that the general term is (1 + a)^n.

## FindLinearRecurrence

Let's try FindLinearRecurrence giving the linear recurrence generating a given sequence of functions:

FindLinearRecurrence[{a + 1, a^2 + 2 a + 1, a^3 + 3 a^2 + 3 a + 1}] // Simplify

{1 + a}


now it might be the best way to use e.g. RSolve:

RSolve[{f[n + 1] == (a + 1) f[n], f == a + 1}, f[n], n]

{{f[n] -> (1 + a)^n}}


## FindSequenceFunction

A bit more straightforward way would be FindSequenceFunction yielding the result in terms of a pure function (if not specified the independent variable):

FindSequenceFunction[{a + 1, a^2 + 2 a + 1, a^3 + 3 a^2 + 3 a + 1,
1 + 4 a + 6 a^2 + 4 a^3 + a^4}]

  (1 + a)^#1 &


or just what you'd expect in traditional form (when the variable is specified):

FindSequenceFunction[{a + 1, a^2 + 2 a + 1, a^3 + 3 a^2 + 3 a + 1,
1 + 4 a + 6 a^2 + 4 a^3 + a^4}, n]// TraditionalForm 