Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ For simplicity, many of the code examples here operate on floating point values
- [function `ƒ`](#function)
- [piecewise function](#piecewise-function)
- [prime `′`](#prime)
- [quantifiers `∀` `∃` `¬`](#quantifiers)
- [more...](#more)

## variable naming conventions
Expand Down Expand Up @@ -582,6 +583,81 @@ function fPrime (x) {

Multiple prime symbols can be used to describe the second derivative *ƒ′′* and third derivative *ƒ′′′*. After this, authors typically express higher orders with roman numerals *ƒ*<sup>IV</sup> or superscript numbers *ƒ*<sup>(n)</sup>.

## quantifiers

Quantifiers are symbols used in mathematical logic statements, such as theorems and proofs. They show up all the time in mathematics. They stand in place of natural, or "human", language phrases.

Quantifiers are usually chained together to create powerful mathematical statements.

They usually look like this:

![quantifiers](http://latex.codecogs.com/svg.latex?%5C%5C%20%5Cforall%20x%20%5Cin%20S%3A%20p%28x%29%5C%5C%20%5Cexists%20y%20%5Cin%20S%3A%20p%28y%29%5C%5C%20z%20%5Cin%20S%2C%20%5Cneg%20p%28z%29)

<!--
\\
\forall x \in S: p(x)\\
\exists y \in S: p(y)\\
z \in S, \neg p(z)
-->

In plain English, the variable is just some element in the set. It can be whatever you like. A predicate is a `function` that takes input(s) and returns a Boolean (`true` or `false`). Take a college-level math course or talk to a mathematician if you want to know more.

For example:

![quantifiers example](http://latex.codecogs.com/svg.latex?%5Cforall%20x%20%5Cin%20%5Ctext%7B%20range%20%7D%20R%20%28%3D%20%280%2C1%29%20%5Csubset%20%5Cmathbb%7BR%7D%29%3A%20%5Cneg%20%5Cexists%20y%20%5Cin%20R%3A%20x%20*%20y%20%3E%201)

This basically states that:
* Let `R` be a range of real numbers from 0 to 1 (non-inclusive)
* Pick any number in `R`, and call it `x`
* It is impossible to find any number `y` in `R` such that `x * y > 1`

If I were to write this as (pseudo-)code it would look like the following:

```js
let claim = forAll(R, function(x) {
let subclaim = forSome(R, function(y) {
return x * y > 1
})

return !subclaim
})

assert(claim)
```

Here's a run-down of what they mean in plain English:

* `∀`: For __All__
* `∃`: For some, there __Exists__
* `¬`: __Not__, it is false that ...

Now for the code (using ES6/Harmony):

```js
//"For all"
function forAll(setOfThings, predicate) {
return Array.from(setOfThings).every(predicate)
}

//Or more explicitly...
function forAllParentalAdvisory(setOfThings, predicate) {
for (let element of setOfThings) {
if (predicate(element) === false) {
return false
}
}

return true
}

//"For some" or "there exists"
function forSome(setOfThings, predicate) {
return Array.from(setOfThings).some(predicate)
}

//"Not" or "negation" -> just use good old `!`
```

## more...

Like this guide? Suggest some [more features](https://github.com/Jam3/math-as-code/issues/1) or send us a Pull Request!
Expand Down