Table of Contents
Fetching ...

Algorithms for complementary sequences

Chai Wah Wu

TL;DR

This work presents a unified fixed-point framework for computing the nth integer that either satisfies or avoids a given predicate P, via the counting function $C_P$ and the map $g_n(x)=n+x-C_P(x)$, linking to the Lambek–Moser method. It develops several algorithmic strategies, including function-iteration, interleaving with an easily invertible auxiliary function, and bisection, with a hybrid approach that often yields efficient computation. The authors derive explicit, single-evaluation formulas for a broad range of complementary sequences, such as non-$k$-gonal, non-$k$-gonal-pyramidal, non-$k$-simplex, non-sum-of-$k$-th-powers, and non-$k$-th-powers, and show how these techniques extend to unions of sequences and sequences with repeated terms. The methods enable rapid, exact computation of $f_P(n)$ and $f_{ eg P}(n)$ in many cases and have practical implications for enumerating OEIS sequences without full enumeration, supported by accompanying code resources. The work thus provides both theoretical insight and practical algorithms for a wide class of counting problems through a fixed-point perspective.

Abstract

Finding the $n$-th positive square number is easy, as it is simply $n^2$. But how do we find the complementary sequence, i.e., the $n$-th positive non-square number? For this case there is an explicit formula. However, for general constraints on numbers, a formula is harder to find. In this paper, we study how to compute the $n$-th integer that does (or does not) satisfy a certain condition. In particular, we consider it as a fixed point problem, relate it to the iterative method of Lambek and Moser, study a bisection approach to this problem, and provide novel formulas for various complementary sequences including the non-$k$-gonal numbers, non-$k$-gonal-pyramidal numbers, non-$k$-simplex numbers, non-sum-of-$k$-th-powers, and non-$k$-th-powers. For example, we show that the $n$-th non $k$-gonal number is given by $n+\text{round}\left(\sqrt{\frac{2n-2+\left\lfloor\frac{k+1}{4}\right\rfloor}{k-2}}\right)$ and that the $n$-th non-second-hexagonal number is $n+\left\lceil\sqrt{\frac{n}{2}}\right\rceil-1$.

Algorithms for complementary sequences

TL;DR

This work presents a unified fixed-point framework for computing the nth integer that either satisfies or avoids a given predicate P, via the counting function and the map , linking to the Lambek–Moser method. It develops several algorithmic strategies, including function-iteration, interleaving with an easily invertible auxiliary function, and bisection, with a hybrid approach that often yields efficient computation. The authors derive explicit, single-evaluation formulas for a broad range of complementary sequences, such as non--gonal, non--gonal-pyramidal, non--simplex, non-sum-of--th-powers, and non--th-powers, and show how these techniques extend to unions of sequences and sequences with repeated terms. The methods enable rapid, exact computation of and in many cases and have practical implications for enumerating OEIS sequences without full enumeration, supported by accompanying code resources. The work thus provides both theoretical insight and practical algorithms for a wide class of counting problems through a fixed-point perspective.

Abstract

Finding the -th positive square number is easy, as it is simply . But how do we find the complementary sequence, i.e., the -th positive non-square number? For this case there is an explicit formula. However, for general constraints on numbers, a formula is harder to find. In this paper, we study how to compute the -th integer that does (or does not) satisfy a certain condition. In particular, we consider it as a fixed point problem, relate it to the iterative method of Lambek and Moser, study a bisection approach to this problem, and provide novel formulas for various complementary sequences including the non--gonal numbers, non--gonal-pyramidal numbers, non--simplex numbers, non-sum-of--th-powers, and non--th-powers. For example, we show that the -th non -gonal number is given by and that the -th non-second-hexagonal number is .
Paper Structure (23 sections, 23 theorems, 50 equations, 2 figures, 3 algorithms)

This paper contains 23 sections, 23 theorems, 50 equations, 2 figures, 3 algorithms.

Key Result

Theorem 1

If $f_{\neg P}(m+1)-f_{\neg P}(m)\geq m$ for all $m$, then $f_P(n) = g_n(g_n(n)) = n+C_{\neg P}(n+C_{\neg P}(n))$.

Figures (2)

  • Figure 1: $g_n(x)$ when $n=4$ and $P(m)$ denote the logical statement "$m$ is prime". The minimal fixed point is at $x=7$ which corresponds to $f_P(4)$, the fourth prime number.
  • Figure 2: Number of steps to find $f_P(n)$ when $P(m)$ denotes the statement "$m$ is a product of exactly $6$ distinct primes".

Theorems & Definitions (33)

  • Theorem 1
  • Theorem 2
  • proof
  • Theorem 3
  • proof
  • Corollary 1
  • proof
  • Corollary 2
  • proof
  • Theorem 4
  • ...and 23 more