sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.31k stars 450 forks source link

catalog of sequences in SageMath #18565

Open dkrenn opened 9 years ago

dkrenn commented 9 years ago

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.

See also the meta-ticket #16107.


Old: See the discussion on sage-devel

Depends on #19896

CC: @mantepse

Component: combinatorics

Author: Daniel Krenn

Branch/Commit: u/dkrenn/sequences/base @ b0bb4fa

Issue created by migration from https://trac.sagemath.org/ticket/18565

dkrenn commented 9 years ago

Description changed:

--- 
+++ 
@@ -18,3 +18,4 @@
 One motivation for creating this, is to include here many sequences, which can be calculated term-by-term (from the previously calculated ones, i.e., recursively) or where the first N terms can be calculated at once efficiently.
 Nevertheless, it can also provide an interface to sequences, where each term can be calculated explicitly (without dealing with the previous ones).

+See the discussion on [sage-devel](https://groups.google.com/forum/#!topic/sage-devel/L-wSCu4fXe8)
videlec commented 9 years ago
comment:2

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

dkrenn commented 9 years ago
comment:3

Dear Vincent,

Replying to @videlec:

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.

videlec commented 9 years ago
comment:4

Replying to @dkrenn:

Replying to @videlec:

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

videlec commented 9 years ago
comment:5

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!

6bdad4c1-1e26-4f2f-a442-a01a2292c181 commented 9 years ago
comment:6

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

dkrenn commented 9 years ago
comment:7

Replying to @videlec:

Replying to @dkrenn:

Replying to @videlec:

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

dkrenn commented 9 years ago
comment:8

Replying to @nathanncohen:

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...

6bdad4c1-1e26-4f2f-a442-a01a2292c181 commented 9 years ago
comment:9

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

mantepse commented 9 years ago
comment:11

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

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

dkrenn commented 8 years ago

Description changed:

--- 
+++ 
@@ -15,7 +15,9 @@

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.

-One motivation for creating this, is to include here many sequences, which can be calculated term-by-term (from the previously calculated ones, i.e., recursively) or where the first N terms can be calculated at once efficiently. -Nevertheless, it can also provide an interface to sequences, where each term can be calculated explicitly (without dealing with the previous ones). +This will use homogenous sequences (#19896), which them-self use lazy lists.

-See the discussion on sage-devel +See also the meta-ticket #16107. + +--- +Old: See the discussion on sage-devel

dkrenn commented 8 years ago

Dependencies: #19896

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 8 years ago

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

cc6d05cmove old sequences file to new place
1136a64fit start on iteration
8e4a562add a doctest in dropwhile
a544d6dcorrect nasty bug in takewhile (complete rewrite of method)
3b63c47simplify `__repr__` code
8354bebMerge branch 'extend_lazy_lists' into t/19896/sequences/homogenous-seq
0330c78Merge branch 'u/dkrenn/sequences/homogenous-seq' of trac.sagemath.org:sage into u/dakrenn/sequences-catalog
d8f6707rewrite sequence generators to new code
74f4c4asequences in global name space (lazy import)
d29cbcduse new code for fibonacci and catalan and deprecate fibonacci_sequence and fibonacci_xrange
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 8 years ago

Changed commit from fa5c40a to d29cbcd

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 8 years ago

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

b384631sequences in index.rst
87136e5rewrite fibonacci-code default argument for "algorithm"
b0bb4faextend docs of sequence_generators
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 8 years ago

Changed commit from d29cbcd to b0bb4fa