Function Repository Resource:

FindLinearRecurrenceEquations

Source Notebook

Find equations describing a linear recurrence corresponding to an input sequence

Contributed by: Max Piskunov and Jan Mangaldan

ResourceFunction["FindLinearRecurrenceEquations"][list,a[n],n]

attempts to find equations describing the minimal linear recurrence a[n] that generates list.

ResourceFunction["FindLinearRecurrenceEquations"][list,a[n],n,d]

attempts to find equations describing the linear recurrence a[n] of maximum order d that generates list.

ResourceFunction["FindLinearRecurrenceEquations"][list]

represents the equations in terms of formal symbols a and n.

Details and Options

ResourceFunction["FindLinearRecurrenceEquations"] gives the equation for the recurrence itself, and the equations for its initial conditions.

Examples

Basic Examples (2) 

Find recurrence equations for the Fibonacci sequence:

In[1]:=
ResourceFunction[
 "FindLinearRecurrenceEquations"][{1, 1, 2, 3, 5, 8}, \[FormalA][\[FormalN]], \[FormalN]]
Out[1]=

Use the default symbols for the recurrence equations:

In[2]:=
ResourceFunction["FindLinearRecurrenceEquations"][{1, 1, 2, 3, 5, 8}]
Out[2]=

A more complicated example:

In[3]:=
ResourceFunction["FindLinearRecurrenceEquations"][
 Table[Fibonacci[k] Fibonacci[k - 1]^2, {k, 10}], \[FormalA][\[FormalN]], \[FormalN]]
Out[3]=

Scope (2) 

Use symbolic data:

In[4]:=
ResourceFunction[
 "FindLinearRecurrenceEquations"][{a, b, a + b, a + 2 b, 2 a + 3 b}, \[FormalA], \[FormalN]]
Out[4]=

Use the default formal symbols to represent the equations:

In[5]:=
ResourceFunction[
 "FindLinearRecurrenceEquations"][{a, b, a + b, a + 2 b, 2 a + 3 b}]
Out[5]=

Use different symbols for the equations:

In[6]:=
ResourceFunction[
 "FindLinearRecurrenceEquations"][{a, b, a + b, a + 2 b, 2 a + 3 b}, f, j]
Out[6]=
In[7]:=
ResourceFunction[
 "FindLinearRecurrenceEquations"][{a, b, a + b, a + 2 b, 2 a + 3 b}, f[j], j]
Out[7]=

Applications (4) 

Generate the convergents of a quadratic irrational:

In[8]:=
cl = Convergents[Sqrt[2], 12]
Out[8]=

Find the recurrence equations for the numerators and denominators:

In[9]:=
nuEqs = ResourceFunction["FindLinearRecurrenceEquations"][
  Numerator[cl], p[j], j]
Out[9]=
In[10]:=
deEqs = ResourceFunction["FindLinearRecurrenceEquations"][
  Denominator[cl], q[j], j]
Out[10]=

Solve the two sets of recurrence equations:

In[11]:=
nuFun = RSolveValue[nuEqs, p[j], j]
Out[11]=
In[12]:=
deFun = RSolveValue[deEqs, q[j], j]
Out[12]=

Verify that the limit at infinity of the ratio of the two solutions is the starting quadratic irrational:

In[13]:=
Limit[nuFun/deFun, j -> \[Infinity]]
Out[13]=

Properties and Relations (4) 

Here are the first few values of the Padovan sequence:

In[14]:=
pado = {1, 1, 1, 2, 2, 3, 4, 5, 7, 9, 12, 16};

Generate the recurrence equation and initial conditions with FindLinearRecurrenceEquations:

In[15]:=
eqs = ResourceFunction["FindLinearRecurrenceEquations"][pado]
Out[15]=

Use RSolve to generate the explicit solution:

In[16]:=
pfunRS = \[FormalA] /. First[RSolve[eqs, \[FormalA], \[FormalN]]]
Out[16]=
In[17]:=
pfunRS[Range[12]] // RootReduce
Out[17]=

Use DifferenceRoot to generate the implicit solution:

In[18]:=
pfunDR = DifferenceRoot[
  Function[{\[FormalA], \[FormalN]}, Evaluate[eqs]]]
Out[18]=
In[19]:=
pfunDR[Range[12]]
Out[19]=

Version History

  • 1.0.0 – 14 April 2020

Related Resources

License Information