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 return compact arrays and 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.27

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

Built distributions (wheels)

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

Total release size: 33.0 MB

Release files / rustymath-0.1.27.tar.gz

Download URL rustymath-0.1.27.tar.gz
Size 2.1 MB
Tags Source
SHA-256 checksum
How to use checksums
f7c17fc50bd62232b9f3b49167f4c8120ec184dfcece3fedabd0c01873eccb3c
BLAKE2b-256 checksum
How to use checksums
5f4c214cba8b24c64be1620d77908bcf1e3908014a3360f0c53c87241efef997
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.27-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rustymath-0.1.27-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.9 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e8819a72b492b2856045f82ff9589cd4dabb0c57268d34b1a9273db87db1abe4
BLAKE2b-256 checksum
How to use checksums
d0c1ff9f3a06b7f8101967c9aadb5beaa251694ceeaa5fb954863463652c38aa
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.27-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL rustymath-0.1.27-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
77fafc9375f74b6ad312017b95c98ba78ee396f7655b20824db71b164028a31b
BLAKE2b-256 checksum
How to use checksums
1a1466b2a91dd6b863a910a37a66c82323b010051f84f323ac395a2c446766ab
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.27-cp313-cp313-macosx_15_0_arm64.whl

Download URL rustymath-0.1.27-cp313-cp313-macosx_15_0_arm64.whl
Size 3.1 MB
Tags CPython 3.13 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
208f846224ae1cc30096eb089cc2c810f39dea1eff6acffab9222bfc259e0e19
BLAKE2b-256 checksum
How to use checksums
e00a47acfe560dd6124eaf3b63ff60fc20a31cd336a4c47dfbe8088fe5e28687
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.27-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rustymath-0.1.27-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.9 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
0f362d301b5a27663e59d6aff3f79cc403cfb595f7e1e107690bdc838869dac5
BLAKE2b-256 checksum
How to use checksums
4723206e04ecff018a020f965e98dc3074d595e61ab80122cdb670582d94915f
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.27-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL rustymath-0.1.27-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
b835666e56d25c9ed8cf2e8d50f1b67d17dfc33980b0164623fa643dd6b537b8
BLAKE2b-256 checksum
How to use checksums
f08ec88cb35a6f7548c0463a0a0c15e2984d1a3345e2d9535aa651bde236cb25
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.27-cp312-cp312-macosx_15_0_arm64.whl

Download URL rustymath-0.1.27-cp312-cp312-macosx_15_0_arm64.whl
Size 3.1 MB
Tags CPython 3.12 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
76cde197c6fb64890ea782187493f639a61594a63936829bd5ccde0edc65b0f0
BLAKE2b-256 checksum
How to use checksums
c649de5dfeaaba27b82b673c01688fbd4c5d192633ebbf98c491cd5202fa186f
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.27-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rustymath-0.1.27-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.9 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
1646d1e3657bf63a84deb84ef42f0e77a277f603745cea355609095408925bce
BLAKE2b-256 checksum
How to use checksums
68b662c0bdca56ad76229bad5bc0edbe8030707082c53c9f6e60b500eddd66fe
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.27-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL rustymath-0.1.27-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
23b425e3d552d78e122d94204e8d6e8d1516e97d78aea3d48c865230a016d5c8
BLAKE2b-256 checksum
How to use checksums
384815651e945fda2e5bc5d761e6df4443fee745f0fec09d96145543424da352
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.27-cp311-cp311-macosx_15_0_arm64.whl

Download URL rustymath-0.1.27-cp311-cp311-macosx_15_0_arm64.whl
Size 3.1 MB
Tags CPython 3.11 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
a0f0e7962212aec2689cd6a9c2b7edc98e0a568ae704a0fb3e6636ed2a6d0815
BLAKE2b-256 checksum
How to use checksums
7fcf25c797111b316afb7262be6509017f8acb898bddd1ac1f6a8c56a6d01abe
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