Skip to main content
QUICK REVIEW

[Paper Review] Counting Square-Free Numbers

Jakub Pawlewicz|arXiv (Cornell University)|Jul 25, 2011
Benford’s Law and Fraud DetectionMathematics3 references4 citations
TL;DR

This paper presents a novel algorithm for counting square-free numbers up to $ n $, achieving $ \tilde{O}(n^{2/5}) $ time complexity and $ \tilde{O}(n^{1/5}) $ memory complexity using a refined summation formula based on the Möbius and Mertens functions. The method enables the computation of $ S(10^{36}) $ in 88 hours using 256 processors, significantly extending the state of the art beyond the prior limit of $ n = 10^{17} $.

ABSTRACT

The main topic of this contribution is the problem of counting square-free numbers not exceeding $n$. Before this work we were able to do it in time (Comparing to the Big-O notation, Soft-O ($\softO$) ignores logarithmic factors) $\softO(\sqrt{n})$. Here, the algorithm with time complexity $\softO(n^{2/5})$ and with memory complexity $\softO(n^{1/5})$ is presented. Additionally, a parallel version is shown, which achieves full scalability. As of now the highest computed value was for $n=10^{17}$. Using our implementation we were able to calculate the value for $n=10^{36}$ on a cluster.

Motivation & Objective

  • To develop a faster algorithm for computing the exact count of square-free numbers up to $ n $, $ S(n) $, beyond the prior $ \tilde{O}(\sqrt{n}) $ bound.
  • To reduce memory complexity from $ O(\sqrt[4]{n}) $ to $ \tilde{O}(n^{1/5}) $, enabling computation on larger $ n $.
  • To design a fully scalable parallel implementation capable of handling $ n = 10^{36} $, extending the known range of $ S(n) $.
  • To verify correctness and scalability through large-scale computation of $ S(10^e) $ for $ e \leq 36 $, including $ S(10^{36}) $.

Proposed method

  • Derives a new formula for $ S(n) $ by splitting the sum over $ d \leq \sqrt{n} $ into two parts: $ d \leq D $ and $ d > D $, with $ D = \tilde{O}(n^{2/5}) $.
  • Reformulates the tail sum $ S_2(n) $ using Iverson brackets and the floor function to group terms by the value of $ \lfloor n/d^2 \rfloor $, enabling efficient summation over ranges of $ d $.
  • Introduces a block-based computation strategy using the Mertens function $ M(x) = \sum_{k=1}^x \mu(k) $, allowing efficient updates via precomputed Möbius function blocks.
  • Employs a work-balancing technique in the parallel version that uses a cost model $ T(a) = t_s a + t_u U(a) $ to distribute blocks of $ d $-values evenly across processors.
  • Uses a shared-memory model with atomic updates for the global sum and Mertens array, ensuring correctness under concurrent access.
  • Applies a hybrid approach: sequential computation for $ e \leq 26 $, parallel for $ e \geq 24 $, with verification across overlapping ranges.

Experimental results

Research questions

  • RQ1Can the time complexity of counting square-free numbers be reduced below $ \tilde{O}(\sqrt{n}) $, and if so, by how much?
  • RQ2What is the optimal trade-off between time and memory complexity in computing $ S(n) $, and can it be reduced to $ \tilde{O}(n^{1/5}) $?
  • RQ3Is it possible to design a fully scalable parallel algorithm for $ S(n) $ that maintains load balance despite non-uniform work distribution?
  • RQ4Can the algorithm be used to compute $ S(n) $ for $ n = 10^{36} $, and how does its performance scale with increasing $ n $?
  • RQ5What is the practical limit of exact computation of $ S(n) $, and how does the new method compare to prior state-of-the-art?

Key findings

  • The proposed algorithm achieves $ \tilde{O}(n^{2/5}) $ time complexity and $ \tilde{O}(n^{1/5}) $ memory complexity, a significant improvement over the prior $ \tilde{O}(\sqrt{n}) $ and $ O(\sqrt[4]{n}) $ bounds.
  • The parallel version of the algorithm is fully scalable, with ideal time closely matching actual computation time across $ e = 24 $ to $ 36 $, indicating effective load balancing.
  • The algorithm successfully computed $ S(10^{36}) $ in 88 hours using 256 processors on a cluster, extending the known maximum $ n $ from $ 10^{17} $ to $ 10^{36} $.
  • The results for $ e \leq 31 $ were verified by both sequential and parallel runs, confirming correctness and consistency across implementations.
  • The work-balancing strategy based on the cost function $ T(a) = t_s a + t_u U(a) $ effectively mitigates load imbalance, especially in high-update regions like $ d \leq \sqrt{D} $.
  • The number of processors is limited to $ \tilde{O}(n^{2/15}) $ due to the overhead of recomputing Mertens function values from scratch for each block.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.