Opened 6 years ago

# catalog of sequences in SageMath

Reported by: Owned by: dkrenn major sage-6.8 combinatorics mantepse Daniel Krenn N/A u/dkrenn/sequences/base b0bb4fa7a2a17ed74d25402a29fd4143473f3580 #19896

similar to

```    graphs.some_graph
```

or to

```    codes.some_code
```

(and similar), I propose to introduce

```    sequences.some_sequence
```

which should provide a unified access point to all possible sequences in SageMath. For example, there is `fibonacci_sequence` in `sage.combinat.combinat`, `binary_recurring_sequence` (somewhere in combinat) and various other code.

This will use homogenous sequences (#19896), which them-self use lazy lists.

--- Old: See the discussion on sage-devel

### comment:1 Changed 6 years ago by dkrenn

• Description modified (diff)

### comment:2 follow-up: ↓ 3 Changed 6 years ago by vdelecroix

Hello Daniel,

Could you define what you mean by sequence. Is it sequence of numbers? Rational numbers? Real numbers? An element of an infinite cartesian power? Because there also are

```sage: words.FibonacciWord('ab')
word: abaababaabaababaababaabaababaabaababaaba...
```

which is an infinite sequence of elements in `{a,b}`.

Vincent

### comment:3 in reply to: ↑ 2 ; follow-up: ↓ 4 Changed 6 years ago by dkrenn

Dear Vincent,

Could you define what you mean by sequence. Is it sequence of numbers? Rational numbers? Real numbers? An element of an infinite cartesian power? Because there also are

```sage: words.FibonacciWord('ab')
word: abaababaabaababaababaabaababaabaababaaba...
```

which is an infinite sequence of elements in `{a,b}`.

What I head in mind is a sequence of numbers (usually intergers, rationals, maybe reals). But of course words are very much related to it. So any ideas/suggestions are very welcome.

### comment:4 in reply to: ↑ 3 ; follow-up: ↓ 7 Changed 6 years ago by vdelecroix

Could you define what you mean by sequence. Is it sequence of numbers? Rational numbers? Real numbers? An element of an infinite cartesian power? Because there also are

```sage: words.FibonacciWord('ab')
word: abaababaabaababaababaabaababaabaababaaba...
```

which is an infinite sequence of elements in `{a,b}`.

What I head in mind is a sequence of numbers (usually intergers, rationals, maybe reals). But of course words are very much related to it. So any ideas/suggestions are very welcome.

Then you are more restrictive than wikipedia in which a sequence is even allowed to be finite. I do not have suggestion beyond having precise specifications. You can perhaps even be explicit in the names by using `number_sequences.*` or `sequences.numbers.*`? But those two looks a bit too much.

Vincent

### comment:5 Changed 6 years ago by vdelecroix

And you also have orthogonal polynomials, orbit of a dynamical system, permutations (i.e. image of the letters), ... Depending on who you are talking to a sequence can be many things!

### comment:6 follow-up: ↓ 8 Changed 6 years ago by ncohen

What about 'integer sequences', like for Sloane? Words are already stored in `word.<tab>`

### comment:7 in reply to: ↑ 4 Changed 6 years ago by dkrenn

Could you define what you mean by sequence. Is it sequence of numbers? Rational numbers? Real numbers? An element of an infinite cartesian power?

What I head in mind is a sequence of numbers (usually intergers, rationals, maybe reals). [...]

Then you are more restrictive than wikipedia in which a sequence is even allowed to be finite.

I am happy to make it as general as needed.

I do not have suggestion beyond having precise specifications.

Like: Finite and infinite sequences where the elements can be any sage objects (but all of the same type/parent)?

Best,

Daniel

### comment:8 in reply to: ↑ 6 ; follow-up: ↓ 9 Changed 6 years ago by dkrenn

What about 'integer sequences', like for Sloane? Words are already stored in `word.<tab>`

Ok. Do you think here of a parametrisation (parameter `ZZ` for integer sequences; like the base for some parent)? I ask, because maybe someone wants to have a sequence of rationals (e.g. Bernoulli numbers) or polynomials (again e.g. Bernoulli). This would then be similar to words with an infinite alphabet...

### comment:9 in reply to: ↑ 8 Changed 6 years ago by ncohen

Ok. Do you think here of a parametrisation (parameter `ZZ` for integer sequences; like the base for some parent)?

No idea. But I do not think that it is related to what this ticket is about. It seems that you want to create a catalog of some sorts, and we just have to figure out a sensible name for it. I do not think that there is any reason to define any kind of interface for the object that it contains.

I also expect that you will find in the (many) combinat class something which can already handle sequences. In this case, it would be better to use it rather than build a new one.

Nathann

### comment:10 Changed 6 years ago by mantepse

• Cc mantepse added

### comment:11 Changed 6 years ago by mantepse

Let me try to summarize the two apparently orthogonal issues here:

• provide an interface for playing with sequences. My favorite ticket attempting this is #16137, together with #16107. This is for sequences indexed by natural numbers, although possibly finite. If I recall correctly, a generalization might be provided by `Family`.
• provide a catalogue of named ("famous") sequences. I believe that #16137 should be general enough to be able to deal with just about any sequence. Is there any need to restrict to a certain type of sequence?

If the scope of this ticket is the second item, there is no conflict. However, a backend would need to be chosen...

### comment:12 Changed 5 years ago by dkrenn

• Dependencies set to #19896
• Description modified (diff)

### comment:13 Changed 5 years ago by dkrenn

• Summary changed from sequences in SageMath to catalog of sequences in SageMath

### comment:14 Changed 5 years ago by git

• Commit changed from fa5c40a727f7149fee86e893fc52f27455622929 to d29cbcd24b28c5bf4ababc8ff5e7b17993e28bd7

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

 ​cc6d05c `move old sequences file to new place` ​1136a64 `fit start on iteration` ​8e4a562 `add a doctest in dropwhile` ​a544d6d `correct nasty bug in takewhile (complete rewrite of method)` ​3b63c47 `simplify __repr__ code` ​8354beb `Merge branch 'extend_lazy_lists' into t/19896/sequences/homogenous-seq` ​0330c78 `Merge branch 'u/dkrenn/sequences/homogenous-seq' of trac.sagemath.org:sage into u/dakrenn/sequences-catalog` ​d8f6707 `rewrite sequence generators to new code` ​74f4c4a `sequences in global name space (lazy import)` ​d29cbcd `use new code for fibonacci and catalan and deprecate fibonacci_sequence and fibonacci_xrange`

### comment:15 Changed 5 years ago by git

• Commit changed from d29cbcd24b28c5bf4ababc8ff5e7b17993e28bd7 to b0bb4fa7a2a17ed74d25402a29fd4143473f3580

Branch pushed to git repo; I updated commit sha1. New commits:

 ​b384631 `sequences in index.rst` ​87136e5 `rewrite fibonacci-code default argument for "algorithm"` ​b0bb4fa `extend docs of sequence_generators`
Note: See TracTickets for help on using tickets.