A mathematical experiment by Gökhan Taha (gtaha23)
The Sigma Function (σ) is an experimental mathematical function that measures the number of successive square-root operations required for a positive integer to converge to 1 under a specified decimal precision.
Unlike the classical summation notation (Σ), this project defines σ as a function for measuring repeated square-root convergence.
The project currently provides high-performance implementations across 4 different programming languages.
For a given positive integer
-
Repeated Square Roots: After
$k$ iterations of applying square roots to$n$ , the value becomes:$$v_k = n^{\frac{1}{2^k}}$$ -
Convergence Condition: The loop terminates immediately when this value drops below or equal to the precision threshold (
$1 + 10^{-p}$ ):$$n^{\frac{1}{2^k}} \le 1 + 10^{-p}$$ -
Isolating
$k$ : Taking the natural logarithm ($\ln$ ) on both sides yields:$$\frac{1}{2^k} \ln(n) \le \ln(1 + 10^{-p}) \implies \frac{\ln(n)}{\ln(1 + 10^{-p})} \le 2^k$$ -
Applying Base-2 Logarithm: Solving for
$k$ using$\log_2$ gives:$$\log_2 \left( \frac{\ln(n)}{\ln(1 + 10^{-p})} \right) \le k$$
Since
To bypass thousands of redundant loop iterations, this project utilizes a highly efficient analytical estimate before running verification checks:
Why it works: According to the Maclaurin series expansion, for extremely small values of
Suppose we evaluate σ(100, 10), meaning n = 100 and precision = 10. Repeated square roots produce the following sequence:
Iteration 0: 100
Iteration 1: 10
Iteration 2: 3.162277660
Iteration 3: 1.778279410
Iteration 4: 1.333521432
Iteration 5: 1.154781985
Iteration 6: 1.074607828
Iteration 7: 1.036632928
...
Eventually, the value becomes indistinguishable from 1 at 10 decimal places (≤ 1 + 10⁻¹⁰). The total count of these steps yields the final value of σ(100).
- 🚀 High-performance C/C++ implementations bypassing heavy loops via logarithmic fast-paths.
- 🐍 Pure Python implementation out of the box with zero setup.
- 🦀 Pure Rust alternative utilizing type-safe arbitrary precision.
- 🔢 Arbitrary Precision Arithmetic preventing data loss during infinite-like convergence.
- 📐 Novel Mathematical Framework modeling square-root decay boundaries.
- 💻 Cross-Platform Compatibility across Linux, macOS, and Windows.
Sigma-Function/
│
├── C/ # Core high-speed C implementation
│ ├── sigma.h
│ ├── sigma.c
│ └── test.c
│
├── C++/ # Object-oriented C++ layer
│ ├── sigmacpp.cpp
│ └── test.cpp
│
├── Python/ # Scripting and prototyping build
│ ├── sigma.py
│ └── test.py
│
├── Rust/ # Modern memory-safe port
│ ├── src/
│ ├── lib.rs
│ │ └── main.rs
| ├── tests/
│ │ └── test.rs
│ ├── Cargo.lock
│ ├── Cargo.toml
│ └── rust-toolchain
│
├── .gitignore
└── README.md
Requires the GNU Multi-Precision (GMP) and GNU MPFR libraries.
- Ubuntu / Debian:
sudo apt update && sudo apt install libgmp-dev libmpfr-dev gcc g++ - Compilation:
gcc sigma.c -o sigma -lmpfr -lgmp g++ sigmacpp.cpp -o sigmacpp -lmpfr -lgmp
- Execution:
./sigma
Requires Python 3.9+. No external dependencies are needed.
python Python/sigma.pyUtilizes high-precision crates (astro-float, astro-float-macro, astro-float-num).
cd Rust
cargo build --release
cargo run| Language | Precision Backend | Performance Rating | Status |
|---|---|---|---|
| C | GNU MPFR + GMP | 🚀 Ultra Fast (Baseline) | ✅ Stable |
| C++ | GNU MPFR + GMP | 🚀 Ultra Fast | ✅ Stable |
| Rust | astro-float + std |
🛡️ Safe / Moderate | ✅ Stable |
| Python | decimal.Decimal |
🐢 Slower / Portable | ✅ Stable |
Standard IEEE 754 floating-point numbers (double, float) quickly return under repeated square roots because numbers converge to
- Pure Python prototype
- High-performance C core port
- Safe Rust port
- Native C++ port
- Detailed mathematical description paper
- Comprehensive performance benchmarks
- Basic Testing
Contributions are heavily welcome! Whether you have ideas for vectorization (AVX/SIMD) optimizations, new language ports (Go, Zig, Julia), or unique mathematical insights about the behavior of
gtaha
- GitHub: @gtaha23
"Exploring mathematics through computation."
⭐ If you find this project interesting or educational, consider giving it a star!