[seqfan] HOPS - Handy Operations on Power Series

Anders Claesson anders.claesson at gmail.com
Wed Dec 30 15:19:21 CET 2015


Dear sequence fans,

I thought I'd share a couple of command line tools I've written (in
Haskell) for working with integer sequences and their generating
functions:

- http://akc.is/hops/
- http://akc.is/sloane/

The first program is the more interesting. It is a tool for (truncated)
power series manipulation. One unusual property of this program is that
implicit definitions in terms of functional equations are automatically
"solved" (by iteration).

$ hops 'c=1+x*c^2'
c=1+x*c^2 =>
{1,1,2,5,14,42,132,429,1430,4862,16796,58786,208012,742900,2674440}

Many of the "usual" transformations are supported. E.g.,

$ hops 'c=1+x*c^2;HANKEL(c)'
c=1+x*c^2;HANKEL(c) => {1,1,1,1,1,1,1,1}

For a full list of operations and transformations currently supported
see http://akc.is/hops/language/

Programs also compose using a special variable "stdin", though renaming
may occur:

$ hops 'c=1+x*c^2' | hops 'HANKEL(stdin)'
f=1+x*f^2;HANKEL(f) => {1,1,1,1,1,1,1,1}

By downloading stripped.gz hops also knows about A-numbers.

$ hops --prec=22 'A101264^2'
A101264^2 => {0,0,1,2,3,2,3,4,4,4,5,6,5,4,6,4,7,8,3,6,8,6,7,10}

Piping through sloane we find that

$ hops --prec=22 'A101264^2' | sloane 

S A002372 0,0,1,2,3,2,3,4,4,4,5,6,5,4,6,4,7,8,3,6,8,6,7,10,8,6,10,
N A002372 Goldbach conjecture: number of decompositions of 2n into
ordered

and so

$ hops --prec=30 'A101264^2 - A002372'
A101264^2-A002372 =>
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

which is a relation that seems to be missing in the OEIS. If we would
like to find more such identities we could try squaring all sequences in
the OEIS. As a test

$ hops --dump | hops 'stdin^2' >/dev/null

takes just over a minute on my 5 year old ThinkPad x220. Filtering out
those squares which are in the OEIS can be achieved by another pipe
through sloane:

$ hops --dump | hops 'stdin^2' | sloane --filter

This is, unfortunately, a lot slower (room for improvements and pull
requests!) and takes around 35 minutes on my laptop.

Finally, I took the liberty of re-implementing Thomas Baruchel's
interesting deconvolution program using hops (and jq). It can be found
under the heading "A more involved example" in the tutorial,
http://akc.is/hops/tutorial/

Comments, questions, suggestions, etc, are of course very welcome.

Cheers,
Anders (http://akc.is/)


More information about the SeqFan mailing list