| Package import | "zappem.net/pub/math/algex" |
|---|---|
| Documentation | https://pkg.go.dev/zappem.net/pub/math/algex |
| Sources | https://github.com/tinkerator/algex |
Algex is a collection of interdependent Go packages for performing basic algebra. The core functionality was developed to solve the inverse kinematics of a 6-axis robot. However, structuring it as a set of stand alone packages provided a motivation for expanding its capabilities.
The documentation for each of the packages can be found on go.dev via this top-level search: zappem.net/pub/math/algex.
The basic command line example is built as follows:
$ go build examples/algex.go
$ ./algex
> x:=a+b
> y:=a-b
> x*y
a^2-b^2
> fn(x,y):=x-y
> list
fn(x,y) := x-y
x := a+b
y := a-b
> fn(a,b)
a-b
> fn(y,x)
-2*b
> exit
exiting
The other included example is examples/ik.go which is the mentioned
inverse kinematics algebra for the saxis
robot:
$ go run examples/ik.go
... a lot of formulas (investigated and solved by hand) ...
There are a number of sub-package modules, and some algex command
tests. You can run them with ./test.sh in the top level directory.
$ ./algex
> (x+y)*(x-y)/(x+y)
x-y
> (x+y)/(x^2-y^2)
1/(x-y)
> 2*(x+y)*(x-y)/(x^2-y^2)
2
> (x+y)*(x-y)/(x+y)^2
(x^2-y^2)/(2*x*y+x^2+y^2)
> tex (x+y)*(x-y)/(x+y)^2
\frac{x^{2} - y^{2}}{2 x y +x^{2} +y^{2}}
> exit
exiting
This last tex output formats inline as \( \frac{x^{2} - y^{2}}{2 x y
+x^{2} +y^{2}} \). Or as a stand alone formula like this (which I want
to simplify to the RHS):
\[ \frac{x^{2} - y^{2}}{2 x y +x^{2} +y^{2}} \rightarrow \frac{x-y}{x+y}. \]
The algex package is distributed with the same BSD 3-clause license
as that used by golang itself.
Use the github algex bug
tracker.