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=int64)

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=float64), 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=int64), firsts=Array([0, 1, 3], dtype=int64), numbers=Array([0, 1, 0, 2], dtype=int64), counts=Array([2, 1, 1], dtype=int64))

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=float64),
 Array([0.11623959, -0.78285485, -2.3346353], dtype=float64))

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=float64)

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=complex128),
 [(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.32

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.32
File Size Uploaded
rustymath-0.1.32.tar.gz 2.1 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for rustymath 0.1.32
File
rustymath-0.1.32-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.32-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ ARM64 Details
rustymath-0.1.32-cp313-cp313-macosx_15_0_arm64.whl CPython 3.13 CPython 3.13 macOS 15.0+ ARM64 Details
rustymath-0.1.32-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.32-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64 Details
rustymath-0.1.32-cp312-cp312-macosx_15_0_arm64.whl CPython 3.12 CPython 3.12 macOS 15.0+ ARM64 Details
rustymath-0.1.32-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.32-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ ARM64 Details
rustymath-0.1.32-cp311-cp311-macosx_15_0_arm64.whl CPython 3.11 CPython 3.11 macOS 15.0+ ARM64 Details

Total release size: 36.0 MB

Release files / rustymath-0.1.32.tar.gz

Download URL rustymath-0.1.32.tar.gz
Size 2.1 MB
Tags Source
SHA-256 checksum
How to use checksums
80494007592033b099fccbac4463d1e626ce56646c24c19dfbb961add3e26e3b
BLAKE2b-256 checksum
How to use checksums
4eeb6c83e889b57c0487b258f58866e29c5a4ed813513bb1b364a7f5ed81cae5
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 18, 2026.

Transparency log

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

Download URL rustymath-0.1.32-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.3 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
5dbcc6896309d60c78f6f289b77292edfe9e01f181e47029041debce16a7c75c
BLAKE2b-256 checksum
How to use checksums
dd0879eef30e1160879ed8d1e087471e71e7f5c26c3d9db5a2a68281282b451d
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 18, 2026.

Transparency log

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

Download URL rustymath-0.1.32-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.6 MB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
706bbd0f728387ab61fc338b24d9dd40364b8c801441b2f9003ac5e15615c011
BLAKE2b-256 checksum
How to use checksums
c76e5014fcbf8e41f63ca58b78211a08d68cda06ce0e2d58fcc26e99b840c125
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 18, 2026.

Transparency log

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

Download URL rustymath-0.1.32-cp313-cp313-macosx_15_0_arm64.whl
Size 3.4 MB
Tags CPython 3.13 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
d40745055a9a7d5efb5239f43bda79d063708c58ae595731137c0246b95e464d
BLAKE2b-256 checksum
How to use checksums
97b05e8867b8b7d1d9f479c473b44506432befaa933f84494910c1fdc06a7cdb
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 18, 2026.

Transparency log

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

Download URL rustymath-0.1.32-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.3 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
ead6999695c05121f6ddc62998f63607dedd320756b2d332810266d029a7ac49
BLAKE2b-256 checksum
How to use checksums
844da56fc1149ebe50d9a5c9ce7b415b494b1eb5bdb8ef8a0aa2a47d1f36300c
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 18, 2026.

Transparency log

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

Download URL rustymath-0.1.32-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.6 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
b3848daafae58eec3ea75838ad59eeeb47c94f131671a356a462a2ceba853b93
BLAKE2b-256 checksum
How to use checksums
5bb9d9194291bdd71dc83131f6cc4f355778e6bec34f619e39a4db8a5cbac903
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 18, 2026.

Transparency log

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

Download URL rustymath-0.1.32-cp312-cp312-macosx_15_0_arm64.whl
Size 3.4 MB
Tags CPython 3.12 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
772a90091ae272d1f5cef1eac3c6ae0cd0a0db3bfb054996b67816fa2f119765
BLAKE2b-256 checksum
How to use checksums
1e58b39e639161fbc934d394d49cc4d877b1f1b49283020f7720ec8be17039aa
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 18, 2026.

Transparency log

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

Download URL rustymath-0.1.32-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.3 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
b355f4a3512d39ee9e32e2302675413cf42c87787fbe218a7243934be2a93704
BLAKE2b-256 checksum
How to use checksums
3fa452e4462005f8f5a253f6c18d3cb77e2e6c9fa33c88dc071ab26f2d845025
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 18, 2026.

Transparency log

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

Download URL rustymath-0.1.32-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.6 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
fde7c226d5e0adabb241e8f2c4f38f494452f94112e2ad5827f3802a95ee090d
BLAKE2b-256 checksum
How to use checksums
ab3b4de68c492d4a2aec7ab243fa59ffa537482ee3c4833c8aef71f637035c91
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 18, 2026.

Transparency log

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

Download URL rustymath-0.1.32-cp311-cp311-macosx_15_0_arm64.whl
Size 3.4 MB
Tags CPython 3.11 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
1a2342f48bb481cf0649f3f4f3248550da68747c6387b7add7e11f39d57c16ad
BLAKE2b-256 checksum
How to use checksums
aeb367f343db90a0bde9f4dad5db228716c6435c76d231f433b5dcd538fd27c2
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 18, 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