Mathematics
This section reviews Rust crates with a mathematical aspect.
For most general-purpose math needs, nalgebra
↗ (linear algebra) and rand
↗ (random numbers) are excellent starting points. For graphics or game development, glam
↗ is often preferred. For statistics, statrs
↗ is comprehensive.If you're doing numerical computing, ndarray
↗. There are also specific crates available for specialized areas like number theory or units of measurement.
Trigonometry
Recipe | Crates | Categories |
---|---|---|
Calculate the Side Length of a Triangle | ||
Verify that tan is Equal to sin Divided by cos | ||
Calculate the Distance Between two Points on Earth |
Linear Algebra
For vectors, matrices, eigenvalues, and eigenvectors, key crates include:
nalgebra
↗: A widely used and mature linear algebra library. Excellent for general-purpose linear algebra.glam
↗: A fast and ergonomic linear algebra library designed for graphics and games. Often preferred in those contexts.ultraviolet
↗: Another linear algebra library, with a focus on graphics.ndarray
↗: For N-dimensional arrays.Essential for numerical computation and data analysis.nalgebra-lapack
↗ provides LAPACK bindings for linear algebra operations.
Recipe | Crates | Categories |
---|---|---|
Calculate Vector Norms | ||
Add Matrices | ||
Multiply Matrices | ||
Multiply a Scalar with a Vector and a Matrix | ||
Invert a Matrix | ||
Compare Vectors | ||
(De)serialize a Matrix |
Probability and Statistics
For random variables, distributions, hypothesis testing, probabilistic models, stochastic processes, and statistical inference, use the following crates:
statrs
↗ is a comprehensive statistics library.- While primarily for random number generation,
rand
↗ also provides some statistical distributions and functions.
Recipe | Crates | Categories |
---|---|---|
Calculate Measures of Central Tendency | ||
Compute the Standard Deviation |
Random Number Generation
To generating random numbers for simulations, cryptography, etc., use rand
↗, a popular and widely used random number generator crate.
See the Randomness chapter.
Statistical
Additional Numeric Types
To work with numeric types beyond what is available in the standard library, use the following crates:
num
↗ provides numeric traits and other utilities.num-bigint
↗ works with arbitrary-precision integers.num-rational
↗ provides rational numbers.
Complex Numbers
num-complex
↗ for working with complex numbers.
Recipe | Crates | Categories |
---|---|---|
Create Complex Numbers | ||
Add Complex Numbers | ||
Use Mathematical Functions on Complex Numbers |
Numerical Analysis
Numerical integration, differentiation, and root-finding.
rust-num
: numerical traits and operations.ndarray
↗: numerical computations.
Optimization
Linear, nonlinear, and integer programming. Convex analysis. Game theory and decision-making models.
argmin
↗ is a pure Rust optimization library.
Differential Equations
Ordinary and partial differential equations and dynamical systems. Stability analysis, chaos theory, and control systems.
Graph Theory
Graphs, networks, and shortest paths.
petgraph
↗ (graph data structures and algorithms).
Discrete Mathematics
Combinatorics, set theory, and logic.
Units of Measurement
uom
↗: A type-safe dimensional analysis library.
Related Topics
- Algorithms.
- Cryptography.
- Plotting and Graphing: Visualization.
- Randomness.
- Sorting.
Applications
- Classical Machine Learning.
- Deep Learning.
- Science.
- Geoscience.
- Neuroscience.
- Robotics.
- Search.
- Simulation.