sirp

Crates.iosirp
lib.rssirp
version0.1.1
sourcesrc
created_at2021-12-13 04:14:32.82286
updated_at2022-01-04 03:54:13.916993
descriptionComputing properties of factorials, k-factorials and SIRPs
homepagehttps://www.rust-cas.org/fun/misc/sirp.html
repositoryhttps://github.com/JASory/SIRP
max_upload_size
id496847
size9,601
(JASory)

documentation

README

SIRP

This is a novelty mathematics crate that computes large factorials, k-factorials and (sequential) interval residue products up to (2^64-1)!. As well as faster-than-naive evaluation of there factorization and logarithms, independently of direct computation.

It currently uses the number-theory library for arbitrary-precision arithmetic.

Note that fast_log and fast_factor have no guarantee of accuracy and are only useful for estimating near-incomputably large values. Fast_log however performs generally quite well, with less than a digit of error in most cases. Fast_factor however uses an estimate based on geometric series and simple division, which is quite poor in most cases, except for 1-factorials, and even then not exact.

Example of computing a single-factorial, a double-factorial and a SIRP

   use sirp::Sirp;
   
   // the factorial, aka the product of all numbers in the interval 1..100
   
   let  factorial_100 = Sirp::new(1,100,1,0).unwrap() ; 
   
   // the double factorial 100!!
   
   let double_100 = Sirp::new(1,100,2,0).unwrap() ;
   
     // the product of all odd numbers in the interval 1..100
     
   let double_odd_100 = Sirp::new(1,100,2,1).unwrap();
   
    // the product of all odd numbers in the interval 50..100
    
   let sirp_50_100 = Sirp::new(50,100,2,1).unwrap();
   
    // generate the digits to display later
    
   factorial_100.gen_digits();
   
   // compute the logarithm near-exactly
   
    double_100.log(10);
    
   // compute the  exact factorization
   
   double_100_odd.factor()
   
   // constant-time (i.e nanosecond) estimate of logarithm 
   
   double_odd_100.fast_log(10);
   
   // Estimate of factor
   
   sirp_50_100.fast_factor()
     
   
    

Etc. . . Sirp is a more generalized approach that includes the factorials, intervals of factorials, and k-factorials See Factorials and SIRPs for a further discussion of this crate and some of the algorithms used.

Commit count: 3

cargo fmt