From 673f88b3ec007fd29443f35c26eae82a1464ffe2 Mon Sep 17 00:00:00 2001 From: LOZORD Date: Tue, 30 Jun 2015 23:58:12 -0700 Subject: [PATCH 1/8] First version of quantifiers section --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/README.md b/README.md index 53deb0d..9f2cb4d 100644 --- a/README.md +++ b/README.md @@ -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 @@ -582,6 +583,53 @@ 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 *ƒ*IV or superscript numbers *ƒ*(n). +## quantifers + +Quantifiers are symbols used in mathematical logic statements, such as theorems and proofs. You'll see them all the time in advanced mathematics. They stand in place of "human" or natural language phrases. + +Quantifiers are usually chained together to create these complicated mathematical statements. + +They usually follow the form: ` in , `. + +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: `∀ planets in Our Solar System, ∃ a planet called "Earth" ` + +Here's a run down of what they mean in plain English: + +* `∀`: For __a__ll +* `∃`: For some, there __e__xists, +* `¬`: 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 +function forSome(setOfThings, predicate) { + return Array.from(setOfThings).some(predicate); +} + +//Negation -> just use good old '!' +``` + +If you are interested in learning more, be sure to look up De Morgan's Laws! + ## more... Like this guide? Suggest some [more features](https://github.com/Jam3/math-as-code/issues/1) or send us a Pull Request! From 07f67ca750d27c935388f5d6f7920c124faf8b85 Mon Sep 17 00:00:00 2001 From: Leo Rudberg Date: Wed, 1 Jul 2015 00:20:11 -0700 Subject: [PATCH 2/8] Fixed section header typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f2cb4d..106b4ea 100644 --- a/README.md +++ b/README.md @@ -583,7 +583,7 @@ 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 *ƒ*IV or superscript numbers *ƒ*(n). -## quantifers +## quantifiers Quantifiers are symbols used in mathematical logic statements, such as theorems and proofs. You'll see them all the time in advanced mathematics. They stand in place of "human" or natural language phrases. From 49ce723faf8e815e9dbfde83b820f6c9be29552a Mon Sep 17 00:00:00 2001 From: LOZORD Date: Wed, 1 Jul 2015 20:40:12 -0700 Subject: [PATCH 3/8] Some final touches --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9f2cb4d..913516f 100644 --- a/README.md +++ b/README.md @@ -597,14 +597,14 @@ For example: `∀ planets in Our Solar System, ∃ a planet called "Earth" ` Here's a run down of what they mean in plain English: -* `∀`: For __a__ll -* `∃`: For some, there __e__xists, +* `∀`: For All +* `∃`: For some, there Exists, * `¬`: Not, it is false that ... Now for the code (using ES6/Harmony): ```js -//For all +//"For all" function forAll(setOfThings, predicate) { return Array.from(setOfThings).every(predicate); } @@ -620,16 +620,14 @@ function forAllParentalAdvisory(setOfThings, predicate) { return true; } -//For some +//"For some" or "there exists" function forSome(setOfThings, predicate) { return Array.from(setOfThings).some(predicate); } -//Negation -> just use good old '!' +//Negation -> just use good old `!` ``` -If you are interested in learning more, be sure to look up De Morgan's Laws! - ## more... Like this guide? Suggest some [more features](https://github.com/Jam3/math-as-code/issues/1) or send us a Pull Request! From bfcfda6857a7fb5d36bd8526683069541f56ac08 Mon Sep 17 00:00:00 2001 From: LOZORD Date: Wed, 1 Jul 2015 20:51:36 -0700 Subject: [PATCH 4/8] Removed semicolons --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cf661ca..ccecb9a 100644 --- a/README.md +++ b/README.md @@ -606,23 +606,23 @@ Now for the code (using ES6/Harmony): ```js //"For all" function forAll(setOfThings, predicate) { - return Array.from(setOfThings).every(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 false } } - return true; + return true } //"For some" or "there exists" function forSome(setOfThings, predicate) { - return Array.from(setOfThings).some(predicate); + return Array.from(setOfThings).some(predicate) } //Negation -> just use good old `!` From 833cdcd39319fb6fcaf43f1226453c5921f269aa Mon Sep 17 00:00:00 2001 From: LOZORD Date: Wed, 1 Jul 2015 21:00:48 -0700 Subject: [PATCH 5/8] Added LaTex representation of quantifiers --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ccecb9a..1d6aeb0 100644 --- a/README.md +++ b/README.md @@ -589,7 +589,16 @@ Quantifiers are symbols used in mathematical logic statements, such as theorems Quantifiers are usually chained together to create these complicated mathematical statements. -They usually follow the form: ` in , `. +They usually look like this: + +![quantifiers](http://latex.codecogs.com/svg.latex?\\&space;\forall&space;x&space;\in&space;S:&space;p(x)\\&space;\exists&space;y&space;\in&space;S:&space;p(y)\\&space;z&space;\in&space;S,&space;\neg&space;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. From 0722def1939885bfeb6c90138a9918b32096bade Mon Sep 17 00:00:00 2001 From: LOZORD Date: Wed, 1 Jul 2015 21:03:57 -0700 Subject: [PATCH 6/8] Hopefully fixed LaTeX URL via encoding --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1d6aeb0..a9c7fa1 100644 --- a/README.md +++ b/README.md @@ -591,7 +591,7 @@ Quantifiers are usually chained together to create these complicated mathematica They usually look like this: -![quantifiers](http://latex.codecogs.com/svg.latex?\\&space;\forall&space;x&space;\in&space;S:&space;p(x)\\&space;\exists&space;y&space;\in&space;S:&space;p(y)\\&space;z&space;\in&space;S,&space;\neg&space;p(z)) +![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)