Categorygithub.com/orsinium-labs/tinymath
repositorypackage
1.1.0
Repository: https://github.com/orsinium-labs/tinymath.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

🧮 tinymath

[ 📚 docs ] [ 🐙 github ]

The fastest Go math library for constrained environments, like microcontrollers or WebAssembly.

  • Optimizes for performance and small code size at the cost of precision.
  • Uses float32 because most microcontrollers (like ESP32) have much faster computation for float32 than for float64.
  • Designed and tested to work with both Go and TinyGo, hence the name.
  • Most algorithms are ported from micromath Rust library.
  • Zero dependency.

📦 Installation

go get github.com/orsinium-labs/tinymath

🔧 Usage

fmt.Println(tinymath.Sin(tinymath.Pi))

🔬 Size

Here is a comparison of WebAssembly binary size (built with TinyGo) when using tinymath vs stdlib math:

functiontinymathstdlibratio
atan10636728%
atan216778221%
exp463272217%
fract166154107%
hypot6720333%
ln19648924%
powf70191677%
round12917175%
sin125123710%
sqrt5757100%
tan138113712%
trunc5757100%

To reproduce: python3 size_bench.py