Ask Your Question
0

The period() method for BinaryRecurrenceSequence not functioning when the period mod m is non-simple

asked 2024-05-27 19:51:10 +0200

D O'D gravatar image

updated 2024-05-28 17:18:07 +0200

Max Alekseyev gravatar image

BinaryRecurrenceSequence is not throwing an error when there is not a simple period.

For instance, the sequence given by S = BinaryRecurrenceSequence(3,2,u0=0,u1=1) considered mod 4 has terms when considered individually: 0, 1, 3, 3, 3, ..... It does (eventually) have a period, it's just not a simple one.

When, however I try S.period(4), sagemath just stops working without throwing an error and I have to kill the kernel. Is there a method to test whether there are non-simple periods, or which otherwise picks up on sequences like this?

Often I run scripts over multiple sequences with different values for the coefficients, so it's not a case of being able to test each sequence in turn whether there will be an issue.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2024-05-28 17:45:03 +0200

Max Alekseyev gravatar image

updated 2024-05-29 22:10:06 +0200

This is definitely a bug, which I reported at https://github.com/sagemath/sage/issu...

Meanwhile you can use a custom (not efficient though) period computing function such as

def myperiod(S,mod):
    T = dict()
    k = 0
    while True:
        t = (S(k)%mod,S(k+1)%mod)
        if t in T:
            return k-T[t]
        T[t] = k
        k += 1

print( myperiod( BinaryRecurrenceSequence(3,2,u0=0,u1=1), 4 ) )
edit flag offensive delete link more

Comments

Thank you - that's helpful! And also for reporting it as a bug :)

D O'D gravatar imageD O'D ( 2024-06-03 14:45:35 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-05-27 19:26:26 +0200

Seen: 177 times

Last updated: May 29