###################################################################### ## PisanoP.txt Save this file as PisanoP.txt # #To use it # stay in the # ## same directory, get into Maple (by typing: maple ) # ## and then type: read PisanoP.txt # ## Then follow the instructions given there # ## # ## Written by Martin Guerra and Doron Zeilberger, Rutgers University # ## DoronZeil at gmail dot com # ###################################################################### print(`First Written: April 2025: tested for Maple 2020 `): print(`Version April 2025 `): print(): print(`This is PisanoP.txt, A Maple package`): print(`To computer the lengths of periods mod m for C-finite sequences`): print(`accompanying Martin Guerra and Doron Zeilberger's article: `): print(`"Experimenting with Generalized Pisano Sequences for C-finite sequences" `): print(): print(`The most current version is available on WWW at:`): print(` http://sites.math.rutgers.edu/~zeilberg/tokhniot/PisanoP.txt .`): print(`Please report all bugs to: DoronZeil at gmail dot com .`): print(): print(`For general help, and a list of the MAIN functions,`): print(` type "ezra();". For specific help type "ezra(procedure_name);" `): print(`For a list of the supporting functions type: ezra1();`): print(): ezra1:=proc() if args=NULL then print(`The SUPPORTING procedures are`): print(` GenPis`): else ezra(args): fi: end: ezra:=proc() if args=NULL then print(` PisanoP.txt: A Maple package for studying generalized Pisano sequences `): print(`The MAIN procedures are: Pis, PisSeq `): print(``): elif nargs=1 and args[1]=GenPis then print(`GenPis(S,m,N): Given a recurrence S=[INI,ope] outputs the first value of n where it starts`): print(`repeating itself, followed by the period after that`): print(`GenPis([[0,1],[1,1]],5,100);`): elif nargs=1 and args[1]=Pis then print(`Pis(S,m,N): Given a recurrence S=[INI,ope] outputs the first time it repeats itself mod m. It keeps trying ip to N. If it can't find it, it returns FAIL. Try:`): print(`Pis([[0,1],[1,1]],5,100);`): elif nargs=1 and args[1]=PisSeq then print(`PisSeq(S,N,M): The sequence of Pisano sequences for the C-finite sequence S mod m starting with m=max({op(S[1]),op(S[2])}):. Try:`): print(`PisSeq([[0,1],[1,1]],10000,100);`): else print(`There is no such thing as`, args): fi: end: #Pis(S,m,N): Given a recurrence S=[INI,ope] outputs the first time it repeats itself mod m. It keeps trying ip to N. If it can't find it, it returns FAIL. Try: #Pis([[0,1],[1,1]],5,100); Pis:=proc(S,m,N) local INI1,L,i,INI,ope,n: INI:=S[1] mod m:ope:=S[2]: L:=nops(INI): if nops(ope)<>L then RETURN(FAIL): fi: INI1:=[op(2..nops(INI),INI),add(INI[L-i]*ope[i+1],i=0..L-1) mod m]: for n from 1 to N while INI1<>INI do INI1:=[op(2..nops(INI1),INI1), add(INI1[L-i]*ope[i+1],i=0..L-1) mod m]: od: if n=N+1 then RETURN(FAIL): fi: n: end: #GenPis(S,m,N): Given a recurrence S=[INI,ope] outputs the first value of n where it starts #repeating itself, followed by the period after that GenPis:=proc(S,m,N) local INI1,L,i,INI,ope,n,gu,j: INI:=S[1] mod m:ope:=S[2]: L:=nops(INI): if nops(ope)<>L then RETURN(FAIL): fi: gu:=[INI]: INI1:=INI: gu:=[INI]: for n from 1 to N do INI1:=[op(2..nops(INI1),INI1), add(INI1[L-i]*ope[i+1],i=0..L-1) mod m]: if member(INI1,{op(gu)}) then for j from 1 to n-1 while gu[j]<>INI1 do od: RETURN([j-1,n-j+1]): else gu:=[op(gu),INI1]: fi: od: FAIL: end: #PisSeq(S,N,M): The sequence of Pisano sequences for the C-finite sequence S. Try: #PisSeq([[0,1],[1,1]],10000,100); PisSeq:=proc(S,N,M) local st,m: st:=max({op(S[1]),op(S[2])}): [seq(GenPis(S,m,N)[2],m=st..M)]: end: