NAME

Math::NumSeq::PrimeIndexPrimes -- primes with prime number indexes

SYNOPSIS

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

DESCRIPTION

This is the sequence of primes which are at prime indexes,

3, 5, 11, 17, 31, 41, 59, 67, 83, 109, 127, 157, 179, 191, ...
starting i=1

The primes begin

index  prime
  1      2
  2      3     <--+ primes at prime indexes
  3      5     <--+
  4      7        |
  5     11     <--+
  6     13        |
  7     17     <--+
  8     19

The primes marked "<--" have an index which is prime too.

Level

Optional level controls how many repetitions of the prime indexing is to be applied. The level is based on the order of primeness by Neil Fernandez in the PrimeIndexOrder sequence.

The default is level=2, asking for primes with an order of primeness >=2. level=1 gives all primes, and level=0 gives all integers.

The next higher level=3 restricts to primes whose index is prime, and then in addition demands that prime is at an index which is prime.

level => 3
5, 11, 31, 59, 127, 179, 277, 331, 431, 599, ...

Successive levels filter further and the remaining values soon become quite large. For example level=11 starts at 9737333 (and is quite slow to generate).

Level Exact

Optional level_type=>'exact' asks for values which have exactly level as their order of primeness.

With the default level 2 this means primes whose index is a prime, but then the index of that index is not a prime, ie. the iterations of prime index stops there,

level_type => 'exact', level => 2
3, 17, 41, 67, 83, 109, 157, 191, 211, 241, 283, 353, ...

Here 11 is not in the sequence because its order of primeness is 3, since 11 is at index 5, 5 is at index 3, 3 is at index 2.

level_type=exact,level=1 means those primes which are at composite indexes. This is all the primes which are not prime index primes, ie. primes not in the default prime-index-primes sequence.

level_type => 'exact', level => 1
2, 7, 13, 19, 23, 29, 37, 43, 47, 53, 61, 71, 73, 79, ...

level_type=exact,level=0 means integers which have order of primeness 0, which is the composites, ie. the non-primes.

FUNCTIONS

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

$seq = Math::NumSeq::PrimeIndexPrimes->new (level => $n)

Create and return a new sequence object.

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

Return an estimate of the i corresponding to $value. $value can be any size.

Formulas

Value to i Estimate

The i for a given value can be estimated by applying the prime-to-i estimate of the plain primes sequence ("Value to i Estimate" in Math::NumSeq::Primes) according to the level parameter.

repeat level many times
  value = Primes value_to_i_estimate(value)

if level_type eq "exact"
  value = value - Primes value_to_i_estimate(value)

i_estimate = value

For example the default level=2 prime index primes applies the Primes estimate twice. A given value is presumed to be a prime, it's index is estimated. Then that index also has to be a prime (so the original value is a prime index prime), and the index of that is again estimated by the Primes module.

For level_type=>'exact' the final index must be a composite, as opposed to "minimum" where it can be either prime or composite. That restriction means an extra final Composite value to i, derived from the Primes by simply

Composite value_to_i_estimate(x)
  = value - Primes value_to_i_estimate(x)

SEE ALSO

Math::NumSeq, Math::NumSeq::Primes, Math::NumSeq::PrimeIndexOrder

HOME PAGE

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

LICENSE

Copyright 2011, 2012, 2013, 2014, 2016 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/>.