The Limits of Python in Computational Mathematics and Their Extension with JAX: An Application on Harmonic Numbers
Version 1

The Limits of Python in Computational Mathematics and Their Extension with JAX: An Application on Harmonic Numbers

Mehmet Keçeci ORCID: https://orcid.org/0000-0001-9937-9839, Independent Researcher

Received: 29.07.2025

Abstract:

This study presents a comparative analysis of a traditional, pure Python-based approach and a modern, JAX library-based approach for calculating the harmonic series, focusing on performance, scalability, and efficiency. The harmonic series is a divergent series of significant importance in mathematical analysis. In computational mathematics, the effective evaluation of such series is critical, particularly in applications requiring large-scale data and high precision. The traditional pure Python approach utilises the fractions.Fraction class to provide exact arithmetic, enhancing the code's readability and accuracy. However, this method exhibits linear time complexity for large values of n, limiting its performance in the context of repetitive calculations. Furthermore, memory usage and processing time increase linearly with n. In contrast, the JAX-based approach (the Oresmej module) leverages the advanced features of JAX, a library designed for high-performance scientific computing, including vectorisation (vmap), just-in-time (JIT) compilation, and automatic differentiation. This approach yields a significant speed advantage, especially in large-scale and repetitive operations. Additionally, caching is supported via @lru_cache, which prevents re-computation for identical inputs. The return value is defined as a tuple, thereby enhancing data integrity and cache compatibility. The comparative analysis was conducted using micro-benchmarking techniques. Following a warm-up period, the JAX-based approach was found to be several hundred times faster than pure Python, with cached functions producing results almost instantaneously. Therefore, for scientific research demanding high performance, scalability, and sustainable computation, approaches based on Cython (Cythonize), Numba, JAX, NumPy, and parallel processing (multiprocessing, joblib) are strongly recommended.

Keywords:

Harmonic Series, Pure Python, JAX, Scientific Computing, Performance Comparison, Caching, Vectorisation, JIT Compilation, Exact Arithmetic, Sustainable Coding, Green Coding, Yeşil Kodlama, Oresme, Oresmej, Numba, Cython, Cythonize, NumPy, Multiprocessing, joblib.

SEEK ID: https://workflowhub.eu/documents/43?version=1

Filename: The Limits of Python in Computational Mathematics and Their Extension with JAX An Application on Harmonic Numbers.pdf  Download

Format: PDF document

Size: 814 KB

DOI: 10.48546/workflowhub.document.43.1

help Creators and Submitter
Creator
Submitter
Citation
Keçeci, M. (2025). The Limits of Python in Computational Mathematics and Their Extension with JAX: An Application on Harmonic Numbers. WorkflowHub. https://doi.org/10.48546/WORKFLOWHUB.DOCUMENT.43.1
Activity

Views: 44   Downloads: 3

Created: 29th Jul 2025 at 18:19

help Attributions

None

Version History

Version 1 (earliest) Created 29th Jul 2025 at 18:19 by Mehmet Keçeci

No revision comments

Powered by
(v.1.17.0-main)
Copyright © 2008 - 2025 The University of Manchester and HITS gGmbH