Kevin Ryde > Math-NumSeq > Math::NumSeq::TwinPrimes

Download:
Math-NumSeq-71.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  2
View/Report Bugs
Module Version: 71   Source  

NAME ^

Math::NumSeq::TwinPrimes -- twin primes

SYNOPSIS ^

 use Math::NumSeq::TwinPrimes;
 my $seq = Math::NumSeq::TwinPrimes->new;
 my ($i, $value) = $seq->next;

DESCRIPTION ^

The twin primes 3, 5, 11, 19, 29, etc, where both P and P+2 are primes.

FUNCTIONS ^

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.

$seq = Math::NumSeq::TwinPrimes->new ()
$seq = Math::NumSeq::TwinPrimes->new (pairs => 'second')

Create and return a new sequence object. The optional pairs parameter (a string) controls which of each twin-prime pair of values is returned

    "first"      the first of each pair, 3,5,11,17 etc
    "second"     the second of each pair 5,7,13,19 etc
    "both"       both values 3,5,7,11,13,17,19 etc
    "average"    the average of the pair, 4,6,12,8 etc

"both" is without repetition, so for example 5 belongs to the pair 3,5 and 5,7, but is returned in the sequence just once.

$bool = $seq->pred($value)

Return true if $value is a twin prime of the given pairs type. For example with "second" pred() returns true when $value is the second of a pair, ie. $value-2 is also a prime.

$i = $seq->value_to_i_estimate($value)

Return an estimate of the i corresponding to $value. Currently this is the asymptotic by Brun

                     value
    i ~= 2 * C * --------------
                 (log(value))^2

with Hardy and Littlewood's conjectured twin-prime constant C=0.66016. In practice it's quite close, being too small by a factor between 0.75 and 0.85 in the small to medium size integers this module might calculate.

SEE ALSO ^

Math::NumSeq, Math::NumSeq::Primes, Math::NumSeq::SophieGermainPrimes

HOME PAGE ^

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

LICENSE ^

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

Math-NumSeq 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-NumSeq 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-NumSeq. If not, see <http://www.gnu.org/licenses/>.

syntax highlighting: