Git Product home page Git Product logo

math-as-code's People

Contributors

0xflotus avatar asmeurer avatar brainsucker avatar cbrown132 avatar chocolateboy avatar conaclos avatar ewjmulder avatar luxcoldury avatar mattdesl avatar mauriciopoppe avatar mrdoob avatar nshen avatar quinn-dougherty avatar styfle avatar swerwath avatar wthtw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

math-as-code's Issues

Improve rendering of images

It appears many notations can also be expressed as unicode. Not sure if it's useful, but it might be worth considering. So far these are the pros / cons I could think of:

pro

  • sharable! It's just plain text so it'll work anywhere.
  • crisper rendering, though saving mathjax output as svg might achieve the same

con

  • it's visually different from formulas out in the wild (e.g. LaTeX rendering)

Example

100
 ∑ i
i=1
100
 ∑ (2i+1)
i=1
 3   6
 ∑   ∑ (3ij)
i=1 j=4
 6
 Π i
i=1
â

Thanks!

:heart:

I thought I was the only one who had a hard time with mathmatical notation. This is exactly what I needed (and what I always thought would be a great idea) to aid my personal CS/game programming studies.

Just thought I'd say thanks! ❤️

Sigma n or i

at the Sigma part:

var sum = 0
for (var i = 1; i <= 100; i++) {
  sum += i
}
var n = 100 // upper bound
var sum = (n * (n + 1)) / 2

shouldn't n be i?

"In mathematics, the := =: and = symbols are used for definition."

In mathematics, the := =: and = symbols are used for definition.

Are all three equivalent? If not, would you kindly explain the differences? If so, would you mention please that they are exchangeable?

Thank you _very much_ for writing this. I have wanted a document like this forever.

Add demo gif to README

Disclaimer: This is a bot

It looks like your repo is trending. The github_trending_videos Instgram account automatically shows the demo gifs of trending repos in Github.

Your README doesn't seem to have any demo gifs. Add one and the next time the parser runs it will pick it up and post it on its Instagram feed. If you don't want to just close this issue we won't bother you again.

Ambiguity in the variable definition section

I think that it should be noted that the JS code isn't equivalent, as in math the '=' sign denotes an alias when used as presented.

I saw that you noted that 'x' is just another name, but further clarification would be beneficial in my opinion.

Hope this helps.

PS: Love your effort. I think it will be useful for a lot of people. If I get some free time, expect some pull requests from me. Keep up the good work.

Number hierarchy and floating point numbers

It's probably worth noting that floating point numbers are rational numbers (as well as real and complex).

The number hierarchy is usually ordered by inclusion:

  1. Natural
  2. Integers
  3. Rational
  4. Real
  5. Complex

It helps in explaining how each type of number contains the previous numbers.

Great page. Just trying to help. Thanks!

Some ideas

  • Missing mathematic symbols like "it exists" or "for all"
  • transitivity, commutativity ... maths vs. informatics
  • column vector (french notation) vs line column (american notation) and therefore the transpose notation.
  • you should add a note concerning implications/risks using almostEqual (ae). A ae B and B ec => A ae C ?
  • In almostEqual() code you should use ulp instead of epsilon (ulp are the least significant bit for float). So the current code is ok for pedagogic point of view. Could be nice to add a note on this topic.
  • A note concerning strict float comparison (a = b).
  • Rational number. You can give a example: 3/5 = (3 * 65536) / (5 * 65536) = 229376/65536 = Q16(229376) So float 0.6 can be written as int 229376.
  • logs: log2(1024) = log2(2^10) = 10.
  • logs: log(1000) = log10(10^3) = 3
  • round: x in [0.0 ... 0.4] => 0 else (x in [0.5 .. 0.9]) => 1
    In C: round(float x) = (int) (x + 0.5f); because cast downgrade the value
  • Can show the different norms for matrix (by column, by lines)
  • discrete time vs continuous time
  • variance / covariance can be inspired by: https://www.youtube.com/watch?v=ieL0jxzLhCE&list=PLX2gX-ftPVXU3oUFNATxGXY90AULiqnWT&index=19

Feature: transpiler

These explanations are really cool, thanks for this. It turns something abstract into something tangible that a developer can play with. To build on this, I would love to see a transpiler that leverages these explanations to turn mathematics into executable javascript, and potentially turn executable javascript into mathematical notation. It would go a long way towards demystifying scientific research for the layprogrammer.

Elements and Sets

I think it might be more mathematically "correct" to use Sets instead of Arrays for Elements ("In"/"Not In"). Most of the time, mathematicians make the assumption that they are working on sets (uniqueness, abstract ordering) instead of lists. I know it depends on usage, especially with respect to game and graphics dev, but I think the ES6/Harmony API for Set is pretty nifty!

dot and cross product

Matrix A dot Matrix B

where the dot is usually a small circle (not sure if there's a unicode character for it)

cross product is also a peculiar x, but is not the same as matrix multiplication or component wise multiplication

Consider writing this as Jupyter notebooks instead of JavaScript

GitHub supports executing and rendering Jupyter notebooks which would be much more maintainable and expressive (especially since you can use numpy to execute all kinds of math operations out of the box).

Another big benefit is that you can have GitHub render math notations for you instead of including lots of images in the repo (+ you get retina support!).

Example on GitHub using Jupyter:

Python version?

I really love this project, and think it could be a fantastic way for math and physics students in particular to become familiar with a programming language.

Any prospect for a Python language version?

SVG Rendering

Some of the SVGs are failing because the site hosting them is 503ing.

Could switch to @blixt's SVG Latex viewer. Or maybe save them (eg gh-readme-scrape) and host them in GitHub since this guide has stabilized for the time being.

Off-by-one in Sigma

sum([k for k in range(100)])

output: 4950

The reference said output: 5050
Which would be

sum([i for i in range(101)])

Ambiguity about Real numbers

Note: Real numbers are also finite, as in, not infinite.

I don't think this expresses well what it is trying to express. I'm guessing that it is referring to the check && isFinite(k) to exclude ∞ (Infinity) from ℝ, which in itself is correct, as infinity is not a Real number. But, saying that "infinity is not a real number" is different from saying that "real numbers are finite". This second way of saying it may confuse people with the fact that "ℝ is of infinite size", i.e. that "there are infinite real numbers".

What I think may mark the difference is that, in english, "Real numbers" usually refers to all of them as a whole, while "A Real number" refers explicitly to any individual Real number. I think a better way of saying this could be something along the lines of "Note: Infinity is not a Real number" or maybe "A Real number is also finite, as in, ∞ ∉ ℝ").

A C++ version of this notebook with some extra notations and implementations

I have personally wrote C++ code representations for all the functions and notations referred in the current readme file and also have implemented some extra features, such as 2D point, 2D line class, 3D point, 3D vector class, and all their calculative functions(addition, negation, dot product, scalar product,perpendicular eqn of a line, parallel eqn of a line). Plus for the ease of use of geometry, I have implemented translation, rotation, scaling etc functions for the above classes. If permitted, I would like to add them in a new file dedicated towards C/C++ developers.

code comment typo in 'intervals' section

the code example goes like this

var b = [nextafter(0, Infinity), 1]                           // interval closed on the left 
var c = [0, nextafter(1, -Infinity)]                          // interval closed on the right

however, I think the correct version is

var b = [nextafter(0, Infinity), 1]                           // interval closed on the right
var c = [0, nextafter(1, -Infinity)]                          // interval closed on the left

natural numbers

{ 0, 1, 2, 3, ... }
{ 1, 2, 3, 4, ... }

The latter is more common in computer science, for example:

function isNaturalNumber (n) {
  return isInteger(n) && n >= 0
}

the latter one is n > 0, not n>= 0
so which one is more common in computer science?

prime symbol

primes represent the next value, for example:

A' = A * MVP
can be thought of as
A *= MVP

The single apostrophe is sometimes referred to as prime. "Matrix A prime is the result of matrix A times matrix MVP"

Better search

Imagine I was looking for some symbol description.
What if I could come here, ⌘ + f, and then search for something, that looks like what I'm looking for.
For example <=> or /=.

A draft for exclamation mark

exclamation mark

The exclamation mark has many uses in mathematics. We can take a look at these as follows.

factorial

Exclamation mark ! in mathematics typically denotes the factorial operation.

factorial

This expression means "the product of the integers from 1 to n". For example, 4! (read four factorial) is 4 × 3 × 2 × 1 = 24.

In JavaScript:

function factorialize(num) {
  if (num < 0) 
        return -1;
  else if (num == 0) 
      return 1;
  else {
      return (num * factorialize(num - 1));
  }
}
factorialize(5);

double factorial

The double factorial is an extension onto the normal factorial function. It is denoted with two exclamation points: a!! .

The double factorial of an integer n is defined recursively as:

doublefactorial1

The double factorial is not defined when n is a negative even integer. Also do not confuse the double factorial for a factorial computed twice.

doublefactorial2

The double in double factorial represents the increment between the values of the terms when the factorial is expanded into a product. In the case of a regular factorial, each factor is decremented by one, from the number 'a' to 1. In the case of a double factorial, each factor is decremented by two.

doublefactorial3

The double factorial terminates with the sequence of evens, for example: 4 × 2 × 0!! or the sequence of odds: eg 5 × 3 × 1!! where 1!! = 0!! = 1.

In JavaScript:

function doublefactorial(num) {
  if (num < 0)
    return -1;
  else if (num == 0 || num == 1)
    return 1;
  return (num * doublefactorial(n - 2));
}

uniqueness

Additionally, exclamation mark can also represent uniqueness in mathematics and logic. The phrase "there is one and only one" is used to indicate that exactly one object with a certain property exists and this sort of quantification is known as uniqueness quantification or unique existential quantification.

Uniqueness quantification is often denoted with the symbols ∃! or ∃=1. For example, the formal statement

uniqueness

may be read aloud as "there is exactly one natural number n such that n - 2 = 4".

subfactorial

If exclamation mark used in front of a number, it can represent a subfactorial. The nth subfactorial (also called the derangement number) is the number of permutations of n objects in which no object appears in its natural place (i.e., "derangements").

The first few values of !n for n=1, 2, ... are 0, 1, 2, 9, 44, 265, 1854, 14833, ... For example, the only derangements of {1,2,3} are {2,3,1} and {3,1,2}, so !3=2. Similarly, the derangements of {1,2,3,4} are {2,1,4,3}, {2,3,4,1}, {2,4,1,3}, {3,1,4,2}, {3,4,1,2}, {3,4,2,1}, {4,1,2,3}, {4,3,1,2}, and {4,3,2,1}, so !4=9.

Sums and formulas for !n include:

subfactorial

modality

In linear logic, the exclamation mark denotes one of the modalities that control weakening and contraction.

The exclamation mark is also used in programming, but not the way it's in mathematics. Several computer languages use "!" at the beginning of an expression to denote logical negation: e.g. "!A" means "the logical negation of A", also called "not A" and A != B means "A is not equal to B".

Resources
https://www.wikiwand.com/en/Exclamation_mark
https://www.wikiwand.com/en/Uniqueness_quantification
https://www.wikiwand.com/en/Derangement
http://mathworld.wolfram.com/Subfactorial.html
https://plato.stanford.edu/entries/logic-linear/
https://math.stackexchange.com/questions/67801/what-does-the-exclamation-mark-do
http://math.wikia.com/wiki/Double_factorial
https://medium.freecodecamp.org/how-to-factorialize-a-number-in-javascript-9263c89a4b38

sqrt(x^2) is not equal to x

The readme says sqrt(x^2) = x. But this is not true in general (take x=-1). In general it's equal to +/- x.

It probably should say sqrt(x)^2 = x, which is always true, and can be taken as a "definition" of the square root.

More Features

The guide is not complete. More planned features:

  • cross product
  • tensor product
  • delta
  • dot product
    • common patterns like clamped dot product with angled brackets too specific I think
  • indefinite integral
  • ƒ - function
  • Heaviside function (step()) possibly too specific; already have sgn
  • common patterns like greek letters vs latin ?

And generally:

  • converting some complex/intimidating expressions into code
  • notation-to-code examples from real papers (e.g. graphics programming papers)

Add (first order) logic

First of all, I think this repository is a great initiative to help programmers delve into and understand theoretical (computer science) literature. However, it would be great if there were more content about the symbols used in (First Order) Logic. Logic sentences are often comprised of just these symbols, making them very hard to read without an intuitive understanding of them.

Personally, I find it very helpful to think about them programmatically when reading them, though not all symbols are equally simple to mentally model.

http://tug.ctan.org/info/undergradmath/undergradmath.pdf provides a nice summary of symbols


#12 is an example of another person with difficulties in this area.

Explain concepts used in papers

Like

"Let x be ..." means x will be defined there, either explicit (you can code it directly) or as an element from an not fully known set, which should be explored in the remainder of the theorem.

"... then there exists a y ..." means y must exist, if the preconditions are met, but we do not neccessarly know how to find y.

And metaconcepts like:

In a paper the author can define anything he wants. There are many papers, which define "if CONDITION is met, the element is called admissable", but there is no general concept of admissable.
Authors also can redefine existing concepts like "in the following we assume all vectors are normed" (this means you need to make sure in your code, your vectors are normed). Some will even admit some easy going notation like "with a bit abusive notation we can write ..."

Calculating Vector Magnitude

What do you think of me adding a pull request to add the vector variable to calculate vector magnitude? Can be done easily with Pythagorean theorem which most people will understand.

Graph Theory

Could I potentially start a section on basic graph theory?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.