NAME

Math::OEIS::Grep - search for numbers in OEIS stripped file

SYNOPSIS

use Math::OEIS::Grep;
Math::OEIS::Grep->search (array => [ 8,13,21,34,55,89 ]);
# prints matches found

# command line
# perl -MMath::OEIS::Grep=-search,123,456,789

DESCRIPTION

This module searches for numbers in a downloaded copy of the OEIS stripped file.

    ~/OEIS/stripped

stripped is a big file of the first few sample values of all OEIS sequences. This grep is an alternative to the OEIS web site search and is good if offline or for mechanically trying a large numbers of searches.

The exact form of the results printout and transformations is not settled. The intention is to do something sensible to find given numbers.

The OEIS names file is used to show the name of a matched sequence, if that file is available. (See Math::OEIS::Names.)

Details

More values than in the OEIS samples will still match. This works by demanding a match of the first few given values but then stopping at either the end of the array or the end of the samples, whichever comes first.

An array of constant values or small constant difference is recognised and not searched, since there's usually too many matches and the OEIS sequence which is a constant or constant difference may not be the first match.

File::Map is used to access the stripped file for searching, if that module is available. This is recommended since mmap is a speedup of about 2x over the fallback plain reading by blocks.

The hints given in the OEIS http://oeis.org/hints.html for web searches apply also to the grep here, namely that it can be worth skipping an initial value or two in case you have some slightly different start but then a known sequence. Perhaps that could be attempted automatically here, if no full match.

Also divide out a small common factor. There's attempts here to automate that here a little by searching for /2 and /4 if no exact match (and doubling *2 also in fact). Maybe more divisions could be attempted, even a full GCD. In practice sequences with common factors are often present when it arises from the sequence definition.

FUNCTIONS

Math::OEIS::Grep->search (array => $aref, ...)

Print matches of the given array values in the OEIS stripped file. The key/value pairs can be

array       => $arrayref (mandatory)
name        => $string
max_matches => $integer (default 10)

array is an arrayref of values to search for. This parameter must be given.

name is printed if matches are found. When doing many searches this identify which one has matched. Eg.

name => "case d=123",

max_matches limits the number of sequences returned. This is intended as a protection against a large number of matches from some small list or frequently occurring values.

COMMAND LINE

The module import accepts a -search option which is designed for use from the command line

perl -MMath::OEIS::Grep=-search,123,456,789
# search and then exit perl

SEE ALSO

Math::OEIS, Math::OEIS::Stripped, File::Map

HOME PAGE

http://user42.tuxfamily.org/math-oeis/index.html

LICENSE

Copyright 2010, 2011, 2012, 2013, 2014 Kevin Ryde

Math-OEIS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Math-OEIS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Math-OEIS. If not, see http://www.gnu.org/licenses/.