A collection of mathematical algorithms
Go to file
filifa faa58bb4dc add readme 2025-11-16 22:37:31 -05:00
cmd add coprime check 2025-11-15 19:41:41 -05:00
internal/lib move stirling methods to public package 2025-11-15 19:34:49 -05:00
lib move stirling methods to public package 2025-11-15 19:34:49 -05:00
.gitignore add .gitignore 2025-08-11 20:48:32 -04:00
COPYING initial commit 2025-08-11 19:41:55 -04:00
README.md add readme 2025-11-16 22:37:31 -05:00
go.mod initial commit 2025-08-11 19:41:55 -04:00
go.sum initial commit 2025-08-11 19:41:55 -04:00
main.go initial commit 2025-08-11 19:41:55 -04:00

README.md

mathtools

mathtools is a program for computing various mathematical results that would be tedious to compute by hand.

Why?

Obviously, libraries, software packages, and websites exist for these sort of calculations, but there are tradeoffs with any approach. Rather than needing to write a script, use a REPL, or load a webpage, this allows for an approach more like standard CLI utilities such as GNU factor.

Generally, I've opted to implement routines for problems that are best solved with algorithms, rather than formulas. For instance, the quadratic formula, while useful, is basically plug and chug, and thus isn't implemented here. On the other hand, determining whether a number is prime is a little more tedious to do by hand, so it's provided as a routine.

Available routines

Available routines include:

  • convergents of a periodic continued fraction
  • solving systems of linear congruences with the Chinese remainder theorem
  • discrete logarithm
  • greatest common divisor
  • primality testing
  • Jacobi symbol
  • modular inverse
  • modular square root
  • multiplicative order
  • integer partitions
  • solving Pell equations
  • primitive root modulo n
  • area of a simple polygon from vertex coordinates
  • sieves for totient function, divisor function, Mobius function, and more
  • repetend of the continued fraction of a square root
  • Stirling numbers
  • summatory functions