HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
Experience-Monks
math-as-code
Learning & Reference2015–2023
Experience-Monks / math-as-code

math-as-code

a cheat-sheet for mathematical notation in code form

27Distinct people
29Mentions
0Explicit recommenders
15.5KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

a cheat-sheet for mathematical notation in code form

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 8–Nov 15 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/15/2026, 2:04:58 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year29 dated mentions

Observed mentions: 2015-06-29 22:34:49 UTC to 2023-03-27 03:46:47 UTC.

02462015-01-01 00:00:00 UTC to 2016-01-01 00:00:00 UTC (exclusive): 6 mentions; 3 submissions, 3 comments20152016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 2 mentions; 1 submissions, 1 comments2017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 5 mentions; 3 submissions, 2 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 7 mentions; 1 submissions, 6 comments2019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20192020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 4 mentions; 1 submissions, 3 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 2 mentions; 1 submissions, 1 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20152015-01-01 00:00:00 UTC2016-01-01 00:00:00 UTC633
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC211
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC532
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC716
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC101
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC413
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC211
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC101
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC101

From the project README

An excerpt from the repository, fetched Nov 13, 2026.

Read the project’s introduction
math-as-code Chinese translation (中文版) Python version (English) This is a reference to ease developers into mathematical notation by showing comparisons with JavaScript code. Motivation: Academic papers can be intimidating for self-taught game and graphics programmers. :) This guide is not yet finished. If you see errors or want to contribute, please open a ticket or send a PR. Note: For brevity, some code examples make use of npm packages. You can refer to their GitHub repos for implementation details. foreword Mathematical symbols can mean different things depending on the author, context and the field of study (linear algebra, set theory, etc). This guide may not cover all uses of a symbol. In some cases, real-world references (blog posts, publications, etc) will be cited to demonstrate how a symbol might appear in the wild. For a more complete list, refer to Wikipedia - List of Mathematical Symbols. For simplicity, many of the code examples here operate on floating point values and are not numerically robust. For more details on why this may be a problem, see Robust Arithmetic Notes by Mikola Lysenko. contents variable name conventions equals = ≈ ≠ := square root and complex numbers √ i dot & cross · × ∘ scalar multiplication vector multiplication dot product cross product sigma Σ - summation capital Pi Π - products of sequences pipes || absolute value Euclidean norm determinant hat â - unit vector "element of" ∈ ∉ common number sets ℝ ℤ ℚ ℕ function ƒ piecewise function common functions function notation ↦ → prime ′ floor & ceiling ⌊ ⌉ arrows material implication ⇒ → equality < ≥ ≫ conjunction & disjunction ∧ ∨ logical negation ¬ ~ ! intervals more... variable name conventions There are a variety of naming conventions depending on the context and field of study, and they are not always consistent. However, in some of the literature you may find variable names to follow a pattern like so: s - italic lowercase letters for scalars (e.g. a number) x - bold lowercase letters for vectors (e.g. a 2D point) A - bold uppercase letters for matrices (e.g. a 3D transformation) θ - italic lowercase Greek letters for constants and special variables (e.g. polar angle θ, theta) This will also be the format of this guide. equals symbols There are a number of symbols resembling the equals sign =. Here are a few common examples: = is for equality (values are the same) ≠ is for inequality (value are not the same) ≈ is for approximately equal to (π ≈ 3.14159) := is for definition (A is defined as B) In JavaScript: // equality 2 === 3 // inequality 2 !== 3 // approximately equal almostEqual(Math.PI, 3.14159, 1e-5) function almostEqual(a, b, epsilon) { return Math.abs(a - b) <= epsilon } You might see the :=, =: and = symbols being used for definition.1 For example, the following defines x to be another name for 2kj. In JavaScript, we might use var to define our variables and provide aliases: var x = 2 * k * j However, this is mutable, and only takes a snapshot of the values at that time. Some languages have pre-processor #define statements, which are closer to a mathematical define. A more accurate define in JavaScript (ES6) might look a bit like this: const f = (k, j) => 2 * k * j The following, on the other hand, represents equality: The above equation might be interpreted in code as an assertion: console.assert(x === (2 * k * j)) square root and complex numbers A square root operation is of the form: In programming we use a sqrt function, like so: var x = 9; console.log(Math.sqrt(x)); //=> 3 Complex numbers are expressions of the form , where is the real part and is the imaginary part. The imaginary number is defined as: . In JavaScript, there is no built-in functionality for complex numbers, but there are some libraries that support complex number arithmetic. For example, using mathjs: var math = require('mathjs') var a = math.complex(3, -1) //=> { re: 3, im: -1 } var b = math.sqrt(-1) //=> { re: 0, im: 1 } console.log(math.multiply(a, b).toString()) //=> '1 + 3i' The library also supports evaluating a string expression, so the above could be re-written as: console.log(math.eval('(3 - i) * i').toString()) //=> '1 + 3i' Other implementations: immutable-complex complex-js Numeric-js dot & cross The dot · and cross × symbols have different uses depending on context. They might seem obvious, but it's important to understand the subtle differences before we continue into other sections. scalar multiplication Both symbols can represent simple multiplication of scalars. The following are equivalent: In programming languages we tend to use asterisk for multiplication: var result = 5 * 4 Often, the multiplication sign is only used to avoid ambiguity (e.g. between two numbers). Here, we can omit it entirely: If these variables represent scalars, the code would be: var result = 3 * k * j vector multiplication To denote multiplication of one vector with a scalar, or element-wise multiplication of a vector with another vector, we typically do not use the dot · or cross × symbols. These have different meanings in linear algebra, discussed shortly. Let's take our earlier example but apply it to vectors. For element-wise vector multiplication, you might see an open dot ∘ to represent the Hadamard product.2 In other instances, the author might explicitly define a different notation, such as a circled dot ⊙ or a filled circle ●.3 Here is how it would look in code, using arrays [x, y] to represent the 2D vectors. var s = 3 var k = [ 1, 2 ] var j = [ 2, 3 ] var tmp = multiply(k, j) var result = multiplyScalar(tmp, s) //=> [ 6, 18 ] Our multiply and multiplyScalar functions look like this: function multiply(a, b) { return [ a[0] * b[0], a[1] * b[1] ] } function multiplyScalar(a, scalar) { return [ a[0] * scalar, a[1] * scalar ] } Similarly, matrix multiplication typically does not use the dot · or cross symbol ×. Matrix multiplication will be covered in a later secti
Read the full README on GitHub

What Hacker News says

7 sources
This. I believe we are ripe for another leap in math education, or at least computer science education. A new approach to teaching that in a generation will make current methods looks like rhetorical algebra. I think this is a great example: https://github.com/Jam3/math-as-code That page is a sort of rosetta stone for me after years of learning to code while also struggling with math notation. I find a similar fog lifts when I look at set theory through the lens of SQL and relation databases. It amazes me that we still can't clearly demonstrate to children why math is important and instantly and universally instill a love and curiosity. Instead we have unforgiving educational models that are "well, you either get it or you don't." It angers me to think of all the potentially _effective_ programmers who get their dreams squashed because th
Read the rest
ey can't pass Calculus II (or other prereq.), and thus are literally not allowed to enroll in a programming course. I didn't know about Karnaugh Maps but I use truth tables constantly in the design phase of tasks. Thank you very much for this. If you've found other tools like this please share. Not really related but for requirements I find gap and SWOT analysis to be vital tools as well as weighted pairwise comparisons. Throw in some UML diagrams and I start feeling good about things. These things impress far more people than they should. </rant>
In Mathematics I Use (2012)

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.