What is it?
Algebraeon is a computational algebra system (CAS) written purely in Rust. It implements algorithms for working with matrices, polynomials, algebraic numbers, factorizations, etc. The focus is on exact algebraic computations over approximate numerical solutions. Algebraeon is in early stages of development and the API subject to change. Algebraeon uses Malachite under the hood for arbitrary sized integer and rational numbers.
There is a for informal discussions about Algebraeon. Contributions are welcome.
As a Rust Library
This is the repository for Algebraeon as a Rust library.
As a Python Library
Algebraeon can also be used as a Python library, though it is not fully featured in that case.
Examples
Factoring Integers
To factor large integers using Algebraeon
use Natural;
use ;
use ToStringSignature;
use FromStr;
let n = from_str.unwrap;
let f = n.clone.factor;
println!;
/*
Output:
706000565581575429997696139445280900 = 2^2 × 5^2 × 6988699669998001 × 1010203040506070809
*/
Algebraeon implements Lenstra elliptic-curve factorization for quickly finding prime factors with around 20 digits.
Factoring Polynomials
Factor the polynomials $x2 - 5x + 6$ and $x{15} - 1$.
use ;
let f = parse_integer_polynomial.unwrap;
println!;
/*
Output:
λ^2-5λ+6 = 1 * (λ-2) * (λ-3)
*/
let f = parse_integer_polynomial.unwrap;
println!;
/*
Output:
λ^15-1 = 1 * (λ-1) * (λ^2+λ+1) * (λ^4+λ^3+λ^2+λ+1) * (λ^8-λ^7+λ^5-λ^4+λ^3-λ+1)
*/
so
x^2 - 5x + 6 = (x-2)(x-3)
x^{15}-1 = (x-1)(x^2+x+1)(x^4+x^3+x^2+x+1)(x^8-x^7+x^5-x^4+x^3-x+1)
Linear Systems of Equations
Find the general solution to the linear system
a \begin{pmatrix}3 \\ 4 \\ 1\end{pmatrix} + b \begin{pmatrix}2 \\ 1 \\ 2\end{pmatrix} + c \begin{pmatrix}1 \\ 3 \\ -1\end{pmatrix} = \begin{pmatrix}5 \\ 5 \\ 3\end{pmatrix}
for integers $a$, $b$ and $c$.
use Integer;
use RingToFinitelyFreeModuleSignature;
use Matrix;
use MetaType;
let m = from_rows;
let y = vec!;
for x in structure
.free_module
.affine_subsets
.affine_basis
/*
Output:
[Integer(0), Integer(2), Integer(1)]
[Integer(1), Integer(1), Integer(0)]
*/
so two solutions are given by $(a, b, c) = (0, 2, 1)$ and $(a, b, c) = (1, 1, 0)$ and every solution is a linear combination of these two solutions; The general solution is given by all $(a, b, c)$ such that
\begin{pmatrix}a \\ b \\ c\end{pmatrix} = s\begin{pmatrix}0 \\ 2 \\ 1\end{pmatrix} + t\begin{pmatrix}1 \\ 1 \\ 0\end{pmatrix}
where $s$ and $t$ are integers such that $s + t = 1$.
Complex Root Isolation
Find all complex roots of the polynomial $$f(x) = x5 + x2 - x + 1$$
use parse_integer_polynomial;
let f = parse_integer_polynomial.unwrap;
// Find the complex roots of f(x)
for root in f.all_complex_roots
/*
Output:
root ≈-1.328 of degree 3
root ≈0.662-0.559i of degree 3
root ≈0.662+0.559i of degree 3
root -i of degree 2
root i of degree 2
*/
Despite the output, the roots found are not numerical approximations. Rather, they are stored internally as exact algebraic numbers by using isolating boxes in the complex plane and isolating intervals on the real line.