algebra for Go
github.com/malcolmston/algebra
Symbolic mathematics — a tiny computer-algebra system.
GitHubports sympy/sympy
A standard-library-only computer-algebra system, a spiritual port of a subset of Python's SymPy. Expressions are immutable trees over symbols, big.Int / big.Rat numbers, named constants and elementary functions — build, simplify, differentiate, integrate, expand, factor and solve, then print them back as readable infix.
Install
shell
$ go get github.com/malcolmston/algebraQuick start
main.go
x := algebra.Sym("x")
f := algebra.MustParse("x^2 + 2*x + 1")
df := algebra.Diff(f, x)
fmt.Println(algebra.Simplify(df)) // 2*x + 2Features
- Immutable expression trees implementing an
Exprinterface - Exact arithmetic via
math/bigintegers & rationals - Calculus:
DiffandIntegrate Simplify,Expand,Factor,Collect,Subs- Equation solving:
Solve(linear & quadratic) Parse/MustParseinfix input, canonical printing