First time here? Check out the FAQ!

Ask Your Question
0

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

asked 0 years ago

D O'D gravatar image

updated 0 years ago

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 0 years ago

Max Alekseyev gravatar image

updated 0 years ago

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 ) )
Preview: (hide)
link

Comments

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

D O'D gravatar imageD O'D ( 0 years ago )

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: 0 years ago

Seen: 308 times

Last updated: May 29 '24