<<RISC`GeneratingFunctions`

Package GeneratingFunctions version 0.8 written by Christian Mallinger
Copyright Research Institute for Symbolic Computation (RISC),
Johannes Kepler University, Linz, Austria

?REPlus

(* defining the sequences of Perrin and Lucas numbers *)

perrin = {a[n+3]-a[n+1]-a[n]==0,a[0]==3,a[1]==0,a[2]==2};
lucas = {a[n+2]-a[n+1]-a[n]==0,a[0]==2,a[1]==1};

(* computing a recurrence for the sum of Perrin and Lucas numbers *)

REPlus[perrin,lucas,a[n]]

?RE*

?RESubsequence

(* Computing a recurrence for all odd-indexed Lucas numbers *)

RESubsequence[lucas,a[n],2n+1]

(* Cauchy product of Perrin and Lucas numbers *)

RECauchy[perrin,lucas,a[n]]

(* defining the Fibonacci sequence *)

fib = {F[n+2]-F[n+1]-F[n]==0,F[0]==0,F[1]==1};

(* Computing the recurrence for the Cauchy product of Fibonacci numbers with the constant sequence 1, i.e., for the partial sum of Fibonacci numbers *)

RECauchy[fib,{F[n]==1},F[n]]

(* Perrin and Lucas numbers are built-in *)

?Perrin

?LucasL

(* creating data for guessing *)

dataL = Table[LucasL[nn],{nn,0,20}];
dataP = Table[Perrin[nn],{nn,0,20}];

?GuessRE

(* Guessing the recurrence for Lucas numbers *)

GuessRE[dataL,a[n]]

(* Guessing the recurrence for Perrin numbers -> need to increase the maximal order used! *)

GuessRE[dataP,a[n]]

GuessRE[dataP,a[n],{0,3},{0,0}]