Here's a though on Sloane's tables: should there be a baseclass that
goes an looks up the values online for all as-yet undefined sequences?
- Robert
On Jan 13, 2007, at 10:36 AM, William Stein wrote:
Hi,
This email concerns the new-in-sage-1.6 file
SAGE_ROOT/devel/sage/databases/sloane_functions.py
Functions that compute some of the sequences in Sloane's tables
EXAMPLES:
Type sloane.[tab] to see a list of the sequences that are defined.
sage: d = sloane.A000005; d
The integer sequence tau(n), which is the number of divisors
of n.
sage: d(1)
1
sage: d(6)
4
sage: d(100)
9
On Fri, 12 Jan 2007 11:20:28 -0800, Jaap Spies <[EMAIL PROTECTED]>
wrote:
I have some questions about the way you set up sloane_functions
database.
It was just a first preliminary version, and probably it will need
substantial
modification to fit with what is really need.
First of all not all sequences allow a direct a(n) to compute the
value
of the sequence a with index n.
True. However, even then computation of a(n) is possible by
computing the
others values of a first. You can add all kinds of methods to the
class "class A000...(SloaneSequence):" that you define for a given
sequence. At the end of the day, also make sure
def _eval(self, n):
gets implemente somehow, e.g., by computing and caching everything
up to n,
then returning the n-th value.
Sequences can be defined as a set/list of numbers that satisfy
some criterion.
Sometimes it is easy to generate such a list, and from this list
it is easy
to return the n-th number.
Functions can be defined as recursive function, e.g the Fibonacci
sequence.
In those cases it can be useful to use generators.
Some recursions can generate tons, I mean tens of sequences.
Iterators?
Add an appropriate function to the SloaneSequence class, e.g.,
def iter(self, nstart, nstop):
...
Calculations may need a function that is not in SAGE. Where do I
include it?
If it general enough that it should be in SAGE, add it to SAGE. If
not, implement
it in the sloane_functions.py file, at least for now.
Example: is_power_of_two(n)
See a111787.sage: def is_power_of_two(n):
Some sequences need other sequences.
That's OK. The code in the sequences doesn't get executed until
all the sequences are created, so a000005 could call a100010 if
it wanted to in its implementation.
Sequences with keyword tabl: tables, triangular or square?
I don't understand this question.
There are 125 K sequences, not all interesting, but ...
Let's give it a try.
We could set it up so
sloane.all.[tab]
gives all implemented sequences in order, and
sloane.triangle.[tab]
gives sequences related to triangles, and
sloane.search( )
searches for implemented sequences with certain strings in their
docstrings,
etc.
But doing all that organization will be easier and more interesting
once
some sequences are implemented.
William
>
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---