#performance #approximation #relative-error

fast-math

Fast, approximate versions of mathematical functions

2 releases

Uses old Rust 2015

0.1.1 Jan 13, 2019
0.1.0 May 10, 2015

#668 in Math

Download history 42442/week @ 2026-02-22 53396/week @ 2026-03-01 58482/week @ 2026-03-08 39231/week @ 2026-03-15 46133/week @ 2026-03-22 40879/week @ 2026-03-29 41488/week @ 2026-04-05 38455/week @ 2026-04-12 42736/week @ 2026-04-19 34010/week @ 2026-04-26 48015/week @ 2026-05-03 51768/week @ 2026-05-10 54495/week @ 2026-05-17 65269/week @ 2026-05-24 63937/week @ 2026-05-31 65704/week @ 2026-06-07

253,515 downloads per month
Used in 204 crates (18 directly)

MIT/Apache

21KB
422 lines

Fast, approximate versions of mathematical functions.

This crate includes implementations of "expensive" mathematical functions that are much faster, at the expense of some accuracy. All functions have good guarantees on accuracy to some degree (both relative and absolute).

Installation

Add this to your Cargo.toml

[dependencies]
fast-math = "0.1"

Examples

let x = 10.4781;
let approx = fast_math::log2(x);
let real = x.log2();
// they should be close
assert!((approx - real).abs() < 0.01);

fast-math

Build Status codecov

Fast, approximate versions of mathematical functions. Includes:

  • Logarithms: log2,
  • Exponentials: exp, exp2,
  • Trigonometric functions: atan, atan2.

Documentation, crates.io.

Dependencies

~75KB