math-as-code
a cheat-sheet for mathematical notation in code form
A cheat sheet that translates mathematical symbols from academic papers, sigma, Greek letters, hats, and pipes, into working JavaScript code snippets, side by side, for programmers who were never taught formal math notation.
math-as-code is a reference guide that takes the mathematical notation you see in academic papers — Greek letters, equals signs, sigmas, hats, pipes — and shows what each symbol means by translating it into code. The motivating problem is simple: many self-taught programmers, particularly game and graphics developers, find themselves blocked by papers full of notation they were never formally taught, even when the underlying idea is something they could implement in a few lines. This project bridges the gap by putting the symbol on one side and a working code snippet on the other.
It is organized like a cheat sheet, walking through topics one at a time: variable name conventions (italic lowercase for scalars, bold lowercase for vectors, bold uppercase for matrices, italic Greek for constants), the equals family (=, ≠, ≈, :=), square roots and complex numbers, the dot and cross operators for scalar and vector multiplication, sigma for summation, capital pi for products, pipes for absolute value and norms, hats for unit vectors, the "element of" symbol, common number sets, function notation, primes, floor and ceiling, logical arrows, negation, and intervals. Each entry shows the symbol, a short description, and a code snippet, with notes when a symbol means different things in different fields. Some examples use small npm libraries — for instance mathjs for complex-number arithmetic — when JavaScript lacks the operation built in.
You would reach for math-as-code when you hit a formula in a paper and want a quick translation rather than a textbook. A Chinese translation and a Python version are also linked from the README. The full README is longer than what was provided.
Where it fits
- Decode a formula from a machine-learning or graphics paper by looking up each symbol and copying the matching code snippet.
- Understand what Greek letters, summation signs, and vector notation mean when reading math-heavy programming tutorials.
- Build a quick reference for game or graphics math by adapting the provided code examples to your own project.