P Function Algorithm

A page about the p func algorithm.

Some tuple, SS, has \ellelements. The ith element is SiS_{i}.

Find a function f(λ)f(\lambda) that equals SλS_{\lambda} when evaluated at some integer between 0λ0 \geq \lambda \geq \ell.

The bound, a()a(\ell)or simply a, on the number of terms for the P function is given by:

a()=log2(log2()+1)+1a(\ell) = \lceil \log_{2}(\log_{2}(\ell)+1)+1\rceil

The P function:

P(a,n)=14q=12a1cos2(nπ2q)P(a, n) = \frac{1}{4}\prod_{q=1}^{2^{a-1}} \cos^{2}(\frac{n \pi}{2^{q}})

When the p function is evaluated it produces a single 1 followed by 2^(2^(a - 1) - 1) - 1 zero then the pattern repeats. This will be used to turn on-and-off terms in SS because the number of zeros will always be greater than the number of elements in SS.

1-D Case

There exist a function f(λ)f(\lambda) that equals SλS_{\lambda} when evaluated at some integer between 0λ>0 \geq \lambda > \ell.

f(λ)=14i=0Siq=12a1cos2((λi)π2q)f(\lambda) = \frac{1}{4}\sum_{i=0}^{\ell} S_{i}\prod_{q=1}^{2^{a-1}} \cos^{2}(\frac{(\lambda - i) \pi}{2^{q}})

N-Dimensional Generalization

This can be generalized into n-dimensions by summing different variables for each dimension.

The number of dimensions is N. The tuple being represented is labeled Sij..NS_{i j ..N}, where each index corresponds to a different dimension. The tuple γ\gammais the representation of a point inside an N-dimensional cube and the value in dimension d is γd\gamma_{d}.

f(λ1,λ2,..,λN)=i=0j=0..N=0Sij..N4Nd=1Nq=12a1cos2((λdγd)π2q)f(\lambda_{1},\lambda_{2}, .. ,\lambda_{N}) = \sum_{i=0}^{\ell}\sum_{j=0}^{\ell}..\sum_{N=0}^{\ell}\frac{S_{i j .. N}}{4^{N}} \prod_{d=1}^{N} \prod_{q=1}^{2^{a-1}} \cos^{2}(\frac{(\lambda_{d} - \gamma_{d}) \pi}{2^{q}})

The N-dimensional f function has N sums each with its own label.

Example

For example the tuple:

S=(0,2,5)S = ( 0, 2, 5 )

f(λ)=2cos(1/8π+1/8πλ)2cos(1/4π+1/4πλ)2cos(1/2π+1/2πλ)2+5cos(1/4π+1/8πλ)2cos(1/2π+1/4πλ)2cos(π+1/2πλ)2 f(\lambda) = 2\cos(-1/8\pi + 1/8\pi \lambda)^2\cos(-1/4\pi + 1/4\pi \lambda)^2\cos(-1/2\pi + 1/2\pi \lambda)^2 + 5\cos(-1/4\pi + 1/8\pi \lambda)^2\cos(-1/2\pi + 1/4\pi \lambda)^2\cos(-\pi + 1/2\pi \lambda)^2

λ\lambda

f(λ)f(\lambda)

SλS_{\lambda}

0

0

0

1

2

2

2

5

5

Application

The indefinite integral of this form

f(x)ndx={g(x)+c1,if n<0.h(x)+c2,otherwise.\int f(x)^{n} dx = \begin{cases} g(x)+c_1, & \text{if $n<0$}.\\ h(x)+c_2, & \text{otherwise}. \end{cases}

Can be rewritten in the form

f(x)ndx=α(n)g(x)+β(n)h(x)+c\int f(x)^n dx = \alpha(n) g(x) + \beta(n) h(x) + c

Where α(n)\alpha(n) and β(n)\beta(n) are given by the p function with S equal to the tuple of length 2n created by the function:

s(q,n)=q2nqns(q, n) = q^{2n} - q^{n}

This function returns q-1 n times and zero n times when written in base q. The tuple is generated by

Si(q,n)=s(q,n)qimodqS_{i}(q,n) = \frac{s(q, n)}{q^{i}} \mod q

Set q equal to two and the tuple becomes an on-off switch for mathematical functions. The functions a(n) and b(n) are inverses of each other.

α(n)=i=0nSi(2,n)P(a(n),ni)\alpha(n) = \sum_{i=0}^{n} S_{i}(2, n) P(a(n), n - i)
β(n)=i=0nSP(a(n),ni)\beta(n) = \sum_{i=0}^{n} S' P(a(n), n-i)

The function SS' is the reverse of SS. The length is known so simply changing the index of the sequence from SiS_{i}to S2niS_{2n-i}.

Last updated

Was this helpful?