Skip to content

A symbolic math module for the Go (Golang) Programming Language.

License

Notifications You must be signed in to change notification settings

MatProGo-dev/SymbolicMath.go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Reference codecov

SymbolicMath.go

A symbolic math module for the Go (Golang) Programming Language. It features a simple, composable API for performing math operations on symbolic expressions and is built to express everything from scalar constants to matrices of polynomials.

Some key features include:

  • Composable operations which allow complex mathematics to be expressed in as few lines as you wish (e.g., x.Transpose().Multiply(Q).Multiply(x))
  • Simple API for defining constants and variables (e.g., Q := getKMatrix.From([][]float64{{1, 0}, {0, 2.0}}))
  • Recognition of gonum matrices and vectors in most operations (e.g., vv1.Plus(mat.NewVecDense(N, []float64{1, 2, 3})))
  • Producing panics instead of errors (i.e., if something strange is written in symbolic math, like the multiplication of two mismatched matrices, then the program will panic instead of returning an error. This way, you can worry about the math and not the error handling.)

Some documentation can be found by clicking the "reference" badge above.

Installation

go get github.com/MatProGo-dev/SymbolicMath.go

Usage

package main

import (
    "fmt"
	getKMatrix "github.com/MatProGo-dev/SymbolicMath.go/get/KMatrix"
    "github.com/MatProGo-dev/SymbolicMath.go/symbolic"
)

func main() {
	// Constants
	N := 2
	x := symbolic.NewVariableVector(N)
	Q := getKMatrix.From(
		[][]float64{
			{1, 0},
			{0, 2.0},
		})
	
	// Create the quadratic polynomial
	quadPoly := x.Transpose().Multiply(Q).Multiply(x)

	// Print the polynomial
	fmt.Println(quadPoly.String())
	
	/* Other stuff... */
}

Further examples can be found in the examples directory.

Related Projects

This project was motivated by the need for a symbolic math package for defining optimization and control theory problems in Go, but symbolic mathematics is a topic that covers a wide range of applications. If this tool is not useful for your purpose, then you might find one of the following projects more helpful:

While other symbolic math libraries exist for Go, they typically focus on:

About

A symbolic math module for the Go (Golang) Programming Language.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages