#real #numbers #computable-real

computable-real

Computable real number

3 releases (breaking)

0.3.0 Mar 23, 2025
0.2.0 Mar 9, 2025
0.1.0 Mar 5, 2025

#6 in #real

Download history 209/week @ 2025-03-03 69/week @ 2025-03-10 76/week @ 2025-03-17 57/week @ 2025-03-24 7/week @ 2025-03-31 4/week @ 2025-04-07 2/week @ 2025-04-14

141 downloads per month
Used in 3 crates

MIT license

53KB
766 lines

This crate provides an API to work with computable real numbers (or recursive real numbers). We represent real numbers as a function that accepts a desired precision level and returns an approximation of the real number. By providing an increasingly smaller precision level, we can approximate the real number to an arbitrary precision.

The idea is from the paper Towards an API for the Real Numbers by H. Boehm, and the overall design and a lot of the functions are from the CR.java and UnaryCRFunction.java files in the Android ART repository.

Example

use computable_real::Real;

let pi = Real::pi();
println!("π = {}", pi.render(10));
assert_eq!(pi.render(10), "3.1415926536");
let sin_pi = pi.clone().sin();
println!("sin(π) = {}", sin_pi.render(10));
assert_eq!(sin_pi.render(10), "0.0000000000");

// We can evaluate and render pi past the limit of f64
println!("π = {}", pi.render(30));
assert_eq!(pi.render(30), "3.141592653589793238462643383280");

Dependencies

~460KB