thales
A comprehensive Computer Algebra System (CAS) library for symbolic mathematics, equation solving, calculus, and numerical methods. Named after Thales of Miletus, the first mathematician in the Greek tradition.
Features
- Expression Parsing - Parse mathematical expressions with full operator precedence
- Equation Solving - Linear, quadratic, polynomial, transcendental, and systems of equations
- Calculus - Differentiation, integration, limits, Taylor series, ODEs
- Numerical Methods - Newton-Raphson, bisection, Brent's method when symbolic fails
- Coordinate Systems - 2D/3D transformations, complex numbers, De Moivre's theorem
- Units & Dimensions - Dimensional analysis and unit conversion
- iOS Support - FFI bindings for Swift via swift-bridge
Installation
[]
= "0.4.2"
Quick Start
Solve an Equation
use ;
Coordinate Transformations
use ;
Documentation
The full documentation is available on docs.rs/thales, including:
- User Guides - Step-by-step tutorials
- API Reference - Complete type and function documentation
- Examples - Working code examples
Guides
| Guide | Description |
|---|---|
| Solving Equations | Linear, quadratic, polynomial, and systems |
| Calculus Operations | Derivatives, integrals, limits, ODEs |
| Series Expansions | Taylor, Maclaurin, Laurent, asymptotic |
| Coordinate Systems | 2D/3D transforms, complex numbers |
| Numerical Methods | Root-finding algorithms |
| Working with Units | Dimensional analysis |
| Error Handling | ThalesError patterns |
LaTeX Support
Thales can parse LaTeX mathematical notation into its internal expression tree via parse_latex.
Supported constructs
| Category | LaTeX syntax | Examples |
|---|---|---|
| Fractions | \frac{num}{denom} |
\frac{1}{2}, \frac{x+1}{y} |
| Square root | \sqrt{x} |
\sqrt{2}, \sqrt{x+1} |
| nth root | \sqrt[n]{x} |
\sqrt[3]{8}, \sqrt[n]{x} |
| Superscripts | x^{n} or x^n |
x^{2}, e^{-x} |
| Subscripts | x_{n} or x_n |
x_{1}, x_{12} |
| Greek letters | \alpha, \beta, \pi, etc. |
\alpha, \theta, \pi |
| Trig functions | \sin, \cos, \tan, etc. |
\sin{x}, \cos(\theta) |
| Logarithms / exp | \ln, \log, \exp |
\ln{x}, \log_{10}{x}, \log_{2}{8} |
| Integrals | \int_{a}^{b} expr \, dx |
\int_{0}^{1} x \, dx, \int x dx |
| Limits | \lim_{x \to a} |
\lim_{x \to 0} x, \lim_{x \to \infty} x |
| Sums | \sum_{i=a}^{b} |
\sum_{i=1}^{10} i |
| Operators | \cdot, \times, \div, \pm |
a \cdot b, 2 \times 3 |
Not yet supported
The following constructs are not currently parsed and will return an error:
- Double/contour integrals:
\iint,\oint - Products:
\prod - Partial derivatives:
\partial - Matrix environments:
\begin{matrix},\begin{pmatrix},\begin{bmatrix}, etc.
Optional LAPACK Acceleration
Enable hardware-accelerated matrix operations (eigenvalues, eigenvectors, QR decomposition, linear system solving) by selecting a LAPACK backend:
# macOS / iOS — links against Apple Accelerate.framework
= { = "0.3", = ["lapack-accelerate"] }
# Linux — uses reference LAPACK (requires liblapack-dev / gfortran)
= { = "0.3", = ["lapack-netlib"] }
# Linux — uses OpenBLAS (requires libopenblas-dev)
= { = "0.3", = ["lapack-openblas"] }
The lapack feature is an alias for lapack-accelerate. Without any LAPACK feature, thales uses pure-Rust implementations for all numerical linear algebra.
iOS Cross-Compilation
Build for iOS with FFI support:
# Add iOS targets
# Build for device
See IOS_BUILD.md for complete iOS integration instructions.
Changelog
See CHANGELOG.md for version history and release notes.
License
MIT License - see LICENSE for details.
Links
- Crate: crates.io/crates/thales
- Documentation: docs.rs/thales
- Repository: github.com/ChrisGVE/thales
- Issues: Report bugs