Skip to main content

rustymath

Rustymath provides fast elementary and special functions, statistics, searching and sorting, random sampling, linear algebra, optimization, polynomials and exact arithmetic in Rust and Python. It is the numerical core of BasedPL.

The Python package needs no NumPy. Its eager operations use the same broadcasting, selection and tolerant-comparison rules as the shared Rust core. For richer array notation, operators and fusion, use BasedPL.

Elementary float functions target four units in the last place (ulps). Rustymath prioritizes speed over last-bit agreement and reproducibility.

Install

pip install rustymath

Rust users can add the crate to Cargo.toml. See Using rustymath from Rust for scalar and slice forms, build settings, accuracy and speed.

import rustymath as rm

Arrays and indexing

Functions take Python numbers, nested lists, rustymath arrays or buffer exporters such as NumPy arrays. Broadcasting aligns leading axes. A two-item vector adds one value to each row of this matrix:

rm.add([[1, 2, 3], [4, 5, 6]], [10, 20])
Array([[11, 12, 13], [24, 25, 26]], dtype=i64)

Arrays and indexing covers construction, dtypes, selection, reshaping, axis names, keys and interoperability.

Maths and statistics

Real and complex functions operate on whole arrays. Float comparisons use a relative tolerance by default:

rm.exp([0., 1, 2]), rm.equal(0.1 + 0.2, 0.3)
(Array([1.0, 2.7182818, 7.3890561], dtype=f64), True)

Maths and statistics covers elementary and special functions, reductions, scans, statistics and tolerant comparison.

Searching, sorting and selection

unique retains first-occurrence order and reports each value’s position, class number and count:

rm.unique([3, 1, 3, 2])
Unique(values=Array([3, 1, 2], dtype=i64), firsts=Array([0, 1, 3], dtype=i64), numbers=Array([0, 1, 0, 2], dtype=i64), counts=Array([2, 1, 1], dtype=i64))

Searching, sorting and selection distinguishes tolerant matching from exact ordering.

Random numbers and distributions

Distributions provide density, cumulative probability, quantiles and seeded sampling:

normal = rm.distribution.normal()
normal.cdf([-1.96, 0, 1.96]), normal.sample(3, seed=0)
(Array([0.024997895, 0.5, 0.9750021], dtype=f64),
 Array([0.11623959, -0.78285485, -2.3346353], dtype=f64))

Random numbers and distributions covers sampling and probability functions.

Linear algebra

Solve real or complex systems, including least-norm solutions for singular or non-square matrices:

rm.linalg.solve([[4., 1], [1, 3]], [1., 2])
Array([0.090909091, 0.63636364], dtype=f64)

Linear algebra covers matrix products, reusable factorizations, decompositions and least squares.

Optimization and iterative solves

Minimize functions, fit residuals or find roots. Here Brent’s method finds where cos x = x:

rm.optimize.root_scalar(lambda x: rm.cos(x) - x, [0, 1]).root
0.7390851350713886

Optimization and iterative solves also covers matrix-free linear systems.

Polynomials, exact arithmetic and number theory

Polynomial coefficients start from the constant term. Number-theory functions accept Python integers of any size:

rm.polynomial.polyroots([-6, 11, -6, 1]), rm.number_theory.factor(2**64 + 1)
(Array([(1+0j), (2-0j), (3+0j)], dtype=c128),
 [(274177, 1), (67280421310721, 1)])

Polynomials, exact arithmetic and number theory includes rational matrix solves and calculations with fractions.Fraction.

Accuracy and speed

The Rust page’s Accuracy and speed section compares each function’s speed with Rust’s standard library. It also explains how the 4-ulp bound holds for f16, with and without fused multiply-add, and for pow and root.

Licence

Apache-2.0. Some algorithms and constants come from SLEEF and Arm Optimized Routines. THIRD-PARTY.md has their notices.

Metadata

Release files for rustymath 0.1.28

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rustymath 0.1.28
File Size Uploaded
rustymath-0.1.28.tar.gz 2.1 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for rustymath 0.1.28
File
rustymath-0.1.28-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
rustymath-0.1.28-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ ARM64 Details
rustymath-0.1.28-cp313-cp313-macosx_15_0_arm64.whl CPython 3.13 CPython 3.13 macOS 15.0+ ARM64 Details
rustymath-0.1.28-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
rustymath-0.1.28-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64 Details
rustymath-0.1.28-cp312-cp312-macosx_15_0_arm64.whl CPython 3.12 CPython 3.12 macOS 15.0+ ARM64 Details
rustymath-0.1.28-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
rustymath-0.1.28-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ ARM64 Details
rustymath-0.1.28-cp311-cp311-macosx_15_0_arm64.whl CPython 3.11 CPython 3.11 macOS 15.0+ ARM64 Details

Total release size: 33.6 MB

Release files / rustymath-0.1.28.tar.gz

Download URL rustymath-0.1.28.tar.gz
Size 2.1 MB
Tags Source
SHA-256 checksum
How to use checksums
63b50c3b707e59bea9e470315628d57c65c598afb79e89f0df914cf3957d8525
BLAKE2b-256 checksum
How to use checksums
6a506312d7067742dd54ffa57e415ad956869e2eab476e7691243f4b78596b5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / rustymath-0.1.28-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rustymath-0.1.28-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.0 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
3efc5dd5bc21ddfc5ed8e34830dffd22a153af174aa28e22eedb69bd2055abb0
BLAKE2b-256 checksum
How to use checksums
179a778dc274910ae1b726185a44db9e94f131d2dce0c081b9fdd0547d720ee5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / rustymath-0.1.28-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL rustymath-0.1.28-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.3 MB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
809c6a74698997da580c7afa95d50dce0f29840ffad468ed4648f1496f38a38d
BLAKE2b-256 checksum
How to use checksums
890765f0ee9d6f66c13125529a490efb6d469e49fd88bb2b871c3e9577e177ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / rustymath-0.1.28-cp313-cp313-macosx_15_0_arm64.whl

Download URL rustymath-0.1.28-cp313-cp313-macosx_15_0_arm64.whl
Size 3.2 MB
Tags CPython 3.13 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
f5852183e7476087035f465aed1cec5c593375ee98668fbec17da50f6c717598
BLAKE2b-256 checksum
How to use checksums
515e88d901989f0eebf070d413975feee643294d7caf1c108978816915cf3e8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / rustymath-0.1.28-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rustymath-0.1.28-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.0 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
f745d7387b91f38cc330a9e7e2fa952ef1d702b973e2559fe894177790feb01f
BLAKE2b-256 checksum
How to use checksums
15f10fa0634bce8173995d182acd2145fa73dd9403867afb65bfd21ee5929de7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / rustymath-0.1.28-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL rustymath-0.1.28-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.3 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
a930802c0e9ba75bc8de008307174193d9137b4f07658a6ec01a946979dcadd5
BLAKE2b-256 checksum
How to use checksums
78b27adaee7e0a01f94aa1d24df5e06ab132a16cec6817f355895af264a46f63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / rustymath-0.1.28-cp312-cp312-macosx_15_0_arm64.whl

Download URL rustymath-0.1.28-cp312-cp312-macosx_15_0_arm64.whl
Size 3.2 MB
Tags CPython 3.12 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
eb52dab35e1d18e7152ac253a248a67cde12b3294e4b5da3bcb9df6f636dccbf
BLAKE2b-256 checksum
How to use checksums
5261fdd22ca3941ef103090192e71ef66c52d0128d791e7be82f38c1d20fd17c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / rustymath-0.1.28-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rustymath-0.1.28-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.0 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
5e07f6a9fcdf62e13d2e9c90281ae20679848d4c2b0209425da89bc8040d4c14
BLAKE2b-256 checksum
How to use checksums
969c1326eb7198b4a42cd0c15fe3e06029b8ec50bca2b94ce66ec68cb9f8b939
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / rustymath-0.1.28-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL rustymath-0.1.28-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.3 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
e8cef93e5b175d716abcb852c0b95d302e08149eccf8e7b4806ddbfb92541c5b
BLAKE2b-256 checksum
How to use checksums
e41b51feb45b7c5392c6cea81794139d05a43996f2d25f7fbc5903b030bfe0ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / rustymath-0.1.28-cp311-cp311-macosx_15_0_arm64.whl

Download URL rustymath-0.1.28-cp311-cp311-macosx_15_0_arm64.whl
Size 3.2 MB
Tags CPython 3.11 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
9dbfc34c4182cf13dccdd05db63f74c3acbe8e01fb3b2876fe28aa4fd61c01df
BLAKE2b-256 checksum
How to use checksums
104c137d5ca747d3693812dfeabe68455bffa3af2293e8f3ee09de36c4e4a70d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page