# quadrecurr disproves that a sequence of integers fits a quadratic recurrence of the form: # C[k]*a[m-k]*a[m+k] + C[k-1]*a[m-k+1]*a[m+k-1] + C[k-2]*a[m-k+2]*a[m+k-2]+ ... + # C[0]*a[m]^2 = 0, for some k. # # quadrecurr takes an integer k, and a list of integers L as its arguments. # # If you wish to determine if your sequence fits a quadratic recurrence as above, you # must choose k as in your proposed recurrence above and L must be a list of any 3*k+1 # consecutive terms of your sequence. # quadrecurr works as follows: # If you wish to determine if your sequence fits a recurrence, # C[2]*a[m-2]*a[m+2] + C[1]*a[m-1]*a[m+1] + C[0]*a[m]^2 = 0, # you will input k=2, and L:=[a[1], a[2], ... , a[7]] for some 7 consecutive a[i] in # your sequence. # quadrecurr will construct the matrix # B:= Matrix[ [a[1]*a[5],a[2]*a[4],a[3]^2], [a[2]*a[6],a[3]*a[5],a[4]^2], # [a[3]*a[7],a[4]*a[6],a[5]^2] ] # If a recurrence of the required form exists, then there exists a linear relation # C[2]*v[1]+C[1]*v[2]+C[0]*v[3]=0 where v[1], v[2] and v[3] are the columns of B. # The columns are therefore linearly dependent and the determinant of B will be 0. # So if quadrecurr returns finds the determinant of B to be non-zero, then we have # proven that no quadratic recurrence of this form exists for your sequence. with(LinearAlgebra): quadrecurr := proc(k,L) local j,i,R,A,B,D, L1, S, A1, B1,n: n:=2*k+1: if nops(L) <> (3*n-1)/2 then print ("For k=",k," ,number of entries in the list L must be (3*k+1)=",(3*k+1)); else for j from 1 to (n+1)/2 do R[j]:=[]; for i from 1 to (n+1)/2 do R[j]:=[op(R[j]),(L[i+j-1]*L[n+j-i])]; od; od; A:=[]; for i from 1 to (n+1)/2 do A:= [op(A),R[i]]; od; B:= Matrix(A); L1:=[seq(a[i],i=1..(3*n-1)/2)]; for j from 1 to (n+1)/2 do S[j]:=[]; for i from 1 to (n+1)/2 do S[j]:=[op(S[j]),(L1[i+j-1]*L1[n+j-i])]; od; od; A1:=[]; for i from 1 to (n+1)/2 do A1:= [op(A1),S[i]]; od; B1:= Matrix(A1); print("Matrix of the form :", B1 , " is B:", B ); D:= Determinant(B); print("Determinant of B is : ", D); if D<>0 then print(" No quadratic recurrence exists for k = ", k); fi: fi: end proc: -------------------------------------------------------------------------- Examples: > quadrecurr(2,[1,3,5,7,9,11,13]); [ 2] [a[1] a[5] a[2] a[4] a[3] ] [ ] "Matrix of the form :", [ 2], [a[2] a[6] a[3] a[5] a[4] ] [ ] [ 2] [a[3] a[7] a[4] a[6] a[5] ] [ 9 21 25] [ ] " is B:", [33 45 49] [ ] [65 77 81] "Determinant of B is : ", 0 > quadrecurr(1,[1,2,3,4]); [ 2] [a[1] a[3] a[2] ] [3 4] "Matrix of the form :", [ ], " is B:", [ ] [ 2] [8 9] [a[2] a[4] a[3] ] "Determinant of B is : ", -5 " No quadratic recurrence exists for k = ", 1