3 releases (breaking)

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

#843 in Math

Download history 260/week @ 2025-03-05 23/week @ 2025-03-12

283 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