Skip to content

💡 High-precision C++ implementation of a novel rational sequence that approximates √n for any natural number using only fractions. Inspired by real analysis and powered by GMP & MPFR, it computes square roots with up to 7 million digits of precision.

License

Notifications You must be signed in to change notification settings

Abega1642/sqrt-higher-precision

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

√ Higher Precision — Constructing Square Roots of Natural Numbers

A high-precision C++ implementation of a novel rational sequence that approximates square roots of natural numbers, inspired by mathematical analysis and powered by GMP and MPFR.


📘 Overview

This project is a C++ translation and extension of the original Java implementation that explores a new rational sequence for approximating square roots of natural numbers. The algorithm is rooted in real analysis and number theory, and is capable of computing square roots with up to 7 million digits of precision.

The core idea is to construct a rational sequence that converges to √m for any natural number m, using a recursive formulation derived from metric space topology and inspired by Euler’s techniques.


🚀 Features

  • Compute √m for any natural number m with arbitrary precision
  • Uses rational arithmetic (fractions) to maintain exactness
  • Powered by GMP and MPFR for high-performance big number computation
  • Includes unit tests comparing results against NASA-verified constants
  • Designed for extensibility and mathematical rigor

🛠️ Dependencies

This C++ version uses:

  • GMP: GNU Multiple Precision Arithmetic Library
  • MPFR: Multiple Precision Floating-Point Reliable Library
  • GoogleTest: for unit testing
  • vcpkg: for dependency management

📦 Installation

1. Clone the Repository

git clone https://github.com/your-username/sqrt-higher-precision.git
cd sqrt-higher-precision

2. Install Dependencies via vcpkg

/path/to/vcpkg/vcpkg install gmp mpfr gtest

3. Build the Project

mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build .

🧪 Running Tests

ctest

Tests compare the computed square roots to high-precision reference values (up to 6 million digits) from NASA’s APOD numerical datasets.


📚 Background

This project originated from a topology course challenge: construct a rational sequence that converges to √2. The result evolved into a general-purpose algorithm for approximating any √m using only rational operations.

The original Java version is available here:
👉 on-the-construction-of-real-numbers


Author: Abegà Razafindratelo

About

💡 High-precision C++ implementation of a novel rational sequence that approximates √n for any natural number using only fractions. Inspired by real analysis and powered by GMP & MPFR, it computes square roots with up to 7 million digits of precision.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published