Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

๐Ÿ“ The fastest and smallest Go math library for constrained environments, like microcontrollers or WebAssembly.

License

Notifications You must be signed in to change notification settings

orsinium-labs/tinymath

Repository files navigation

๐Ÿงฎ 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:

function tinymath stdlib ratio
atan 106 367 28%
atan2 167 782 21%
exp 463 2722 17%
fract 166 154 107%
hypot 67 203 33%
ln 196 4892 4%
powf 701 9167 7%
round 129 171 75%
sin 125 1237 10%
sqrt 57 57 100%
tan 138 1137 12%
trunc 57 57 100%

To reproduce: python3 size_bench.py

About

๐Ÿ“ The fastest and smallest Go math library for constrained environments, like microcontrollers or WebAssembly.

Topics

Resources

License

Stars

Watchers

Forks

AltStyle ใซใ‚ˆใฃใฆๅค‰ๆ›ใ•ใ‚ŒใŸใƒšใƒผใ‚ธ (->ใ‚ชใƒชใ‚ธใƒŠใƒซ) /