Kevin Ryde > Math-NumSeq-65 > Math::NumSeq::PrimeIndexPrimes

Math-NumSeq-65.tar.gz

Dependencies

Annotate this POD

Website

# CPAN RT

 Open 0
View/Report Bugs
Module Version: 65   Source   Latest Release: Math-NumSeq-69

# 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.

http://www.borve.org/primeness/FOP.html

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=>10` starts at 9737333.

## 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 PIP 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 -= 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)```

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