Difference between revisions of "User:Francis Tyers/Maths"

From Apertium
Jump to navigation Jump to search
(Created page with '<pre> i = 0; for(n = 0; n < 10; n++) { i = i + i; } </pre> <math>\sum_{i=0}^{10} i</math>')
 
Line 8: Line 8:


<math>\sum_{i=0}^{10} i</math>
<math>\sum_{i=0}^{10} i</math>


== Kronecker Delta and Iverson Notation ==

The [http://en.wikipedia.org/wiki/Kronecker_delta Kronecker Delta] function below allows you to transform logical expressions into 0 and 1 integer values available for summing over sets, or for removing terms from an equation where you multiply a given term by the delta to keep it in or not dependent on some logical restriction.

<math>
\delta_{ij} = \left\{\begin{matrix}
0, & \mbox{if } i \ne j \\
1, & \mbox{if } i=j
\end{matrix}\right.
</math>

In computer science this function became so useful for expressing algorithms it's frequently described using a more lightweight and intuitive notation called the [http://en.wikipedia.org/wiki/Iverson_bracket Iverson bracket] popularised by [http://en.wikipedia.org/wiki/Kenneth_E._Iverson Kenneth E. Iverson]. The Iverson bracket is similarly defined as the Kronecker Delta:

<math>
[f] = \left\{\begin{matrix}
1, & \text{if } f \text{ is true;} \\
0, & \text{otherwise.}
\end{matrix}\right.
</math>

Imagine we wish to count the total number of instances of "the" in an array of words from a piece of text:

<pre>
count = 0
for word in words
count += 1 if word == "the"
print count
</pre>

With Iverson bracket notation we would write this thusly:

<pre>
let W be a set of sequences of characters from the English alphabet
let c be the sum of sequences w that are equal to (t,h,e)
</pre>
<math>
c = \sum_{w \in{} W}^{} [w = (t,h,e)]
</math>

Revision as of 14:07, 22 September 2012

i = 0;
for(n = 0; n < 10; n++)
{
  i = i + i;
}


Kronecker Delta and Iverson Notation

The Kronecker Delta function below allows you to transform logical expressions into 0 and 1 integer values available for summing over sets, or for removing terms from an equation where you multiply a given term by the delta to keep it in or not dependent on some logical restriction.

In computer science this function became so useful for expressing algorithms it's frequently described using a more lightweight and intuitive notation called the Iverson bracket popularised by Kenneth E. Iverson. The Iverson bracket is similarly defined as the Kronecker Delta:

Imagine we wish to count the total number of instances of "the" in an array of words from a piece of text:

count = 0
for word in words
    count += 1 if word == "the"
print count

With Iverson bracket notation we would write this thusly:

let W be a set of sequences of characters from the English alphabet
let c be the sum of sequences w that are equal to (t,h,e)