Wikipedia:School and university projects/Discrete and numerical mathematics/Learning plan/Sandbox

Minihackathons
Important: This section comes from Epistemowikia, although, to prevent confusion, the corresponding page has been whitened there, but you can see its history here.

Definition
A combination with repetition is a mapping from a set $$A$$ into $$\left\lbrace 0, 1, \ldots, k \right\rbrace$$, such that it assigns to every element in $$A$$, the number of times that it occurs repeteadly (between $$0$$ and $$k$$), under the condition that their sum is $$k$$.

Theorem
The total number of these combinations with repetition is: $$\begin{align} CR_{n,k} &= \binom{n+k-1}{k} \end{align} \ \ \ \ \ (1)$$

An alternative notation for $$CR_{n,k}$$ is $$\left(\!\!\binom{n}{k}\!\!\right)$$.

Interpretations

 * $$CR_{n,k}$$ is the total number of selections, with repetition, of size $$k$$, from a collection of $$n$$ objects.
 * $$CR_{n,k}$$ is the total number of multisets of $$k$$ elements from a set of $$n$$ elements.
 * $$CR_{n,k}$$ is the total number of ways of distributing $$k$$ objects among $$n$$ people.
 * $$CR_{n,k}$$ is the total number of integer solutions of the equation $$x_1 + x_2 + \cdots + x_n = k$$, where $$x_i \geq 0$$, for all $$i \in \left\lbrace 1, 2, \ldots, n \right\rbrace$$.
 * $$CR_{n,k}$$ is the total number of ways of distributing $$k$$ indistinguishable objects into $$n$$ distinguishable bins, without any restrictions.

Theorem
Trivially: $$\begin{align} CR_{n,k} &= C_{n+k-1,k} \end{align} \ \ \ \ \ (2)$$

Derivative interpretations, I

 * $$CR_{n,k}$$ is the total number of subsets of $$k$$ elements from a set of $$n+k-1$$ elements.
 * $$CR_{n,k}$$ is the total number of paths on a grid of size $$k \times (n-1)$$.
 * $$CR_{n,k}$$ is the total number of finite sequences of ones and zeros, of length $$n+k-1$$, that contains exactly $$k$$ ones and $$n-1$$ zeros.

Theorem
Trivially: $$\begin{align} CR_{n,k} &= PR_{n-1,k} \end{align} \ \ \ \ \ (3)$$

Derivative interpretations, II

 * $$CR_{n,k}$$ is the total number of surjective mappings from a set $$A$$ of $$n+k-1$$ elements into a set of $$2$$ elements, $$B = \left\lbrace b_1, b_2 \right\rbrace$$, under the following conditions: $$n-1$$ elements of $$A$$ have the same image $$b_1 \in B$$ and $$k$$ elements of $$A$$ have the same image $$b_2 \in B$$, where $$\left( \forall i,j \right) \left( i \neq j \Rightarrow b_i \neq b_j\right)$$.
 * $$CR_{n,k}$$ is the total number of words of length $$n+k-1$$ in which it occurs only two letters $$l_1$$ and $$l_2$$ from a certain alphabet, albeit one occurs $$n-1$$ times and the other is repeated $$k$$ times.



General divisibility rule (base $$10$$)
Let us consider $$k \in \mathbb{Z}^+$$, $$I = \left\lbrace 0, \ldots, k \right\rbrace$$ and $$n = n_0 + n_1 \cdot 10 + n_2 \cdot 10^2 + \cdots + n_k \cdot 10^k$$, where $$(\forall i \in I) (n_i \in \mathbb{N} \wedge 0 \leq n_i < 10)$$. For all $$i \in I$$, let $$r_i$$ be the $$i^\text{th}$$-potential residue of $$10$$, modulo $$m$$, that is, $$10^i \equiv r_i (mod \; m)$$. Then: $$m \mid n \Leftrightarrow m \mid \left( n_0 + n_1 r_1 + n_2 r_2 + \cdots + n_k r_k \right)$$.

General divisibility rule (any base)
Let us consider $$k \in \mathbb{Z}^+$$, $$I = \left\lbrace 0, \ldots, k \right\rbrace$$ and $$n = n_0 + n_1 \cdot b + n_2 \cdot b^2 + \cdots + n_k \cdot b^k$$, where $$(\forall i \in I) (n_i \in \mathbb{N} \wedge 0 \leq n_i < b)$$. For all $$i \in I$$, let $$r_i$$ be the $$i^\text{th}$$-potential residue of $$b$$, modulo $$m$$, that is, $$b^i \equiv r_i (mod \; m)$$. Then: $$m \mid n \Leftrightarrow m \mid \left( n_0 + n_1 r_1 + n_2 r_2 + \cdots + n_k r_k \right)$$.

Concepts
Inverse programming gets information about any product available to the public. When we apply it to skip software protections is usually called Cracking. This engineering tries to take an element, a determinated product, to study its behaviour and composition and duply a program faithfuly.

This method is called that way because it proceeds in the inverse direction of the usual ingineering tasks, which consists in using technical data to elaborate a determinated product.

Generally if the product or another material which was submtted to inverse programming was obtained properly, then the process is legal. In the same way, generic products made with this technique can be legally distributed.

Samba is an example of this kind of engineering as it lets operative systems UNIX to share archives with Windows systems. Samba proyect had to investigate confidential information about technical aspects related with Windows O.S. WINE is another example, which works with Windows’ API and OpenOffice.org with Microsoft Office formats. It is also made to understand NTFS archive system structure so it can be possible to develop drivers to read and write upon itself. (mainly for GNU/Linux based systems).

Inverse programming is a resolution method. Applying it to something suppose to deepen in the study of its operation until we cand understand, modify and improve it.

Examples
An example of a program which is, at the same time its inverse program can be easyly implemented on Python. This example requires a password and a sentence to encrypt. Then it execute  (L = length(C)). If the operation is repeated on the result of F', F is obtained again.

Listing in lexicographic order
Let $$\left\lbrace a_1, \ldots, a_n \right\rbrace$$ be a set of labels (letters, numbers...) for the objects, so distinguishables.

Lexicographic order:

$$ \left( \sigma_i(a_1), \ldots, \sigma_i(a_n) \right) \prec \left( \sigma_j(a_1), \ldots, \sigma_j(a_n) \right) \Leftrightarrow \exists k \in \lbrace 1, \ldots, n \rbrace, \begin{align} \sigma_i(a_1) &= \sigma_j(a_1) \\ &\wedge \\ \sigma_i(a_2) &= \sigma_j(a_2) \\ &\wedge \\ &\vdots \\ &\wedge \\ \sigma_i(a_{k-1}) &= \sigma_j(a_{k-1}) \\ &\wedge \\ \sigma_i(a_k) &< \sigma_j(a_k) \end{align} $$

Generating the next permutation in lexicographic order:

Note that:

If $$\sigma_i(a_{n-1}) < \sigma_i(a_n)$$, then, $$\operatorname{swap}\left( \sigma_i(a_{n-1}), \sigma_i(a_n) \right)$$.

For example, 1234576 follows to 1234567 in the sequence.

If $$\sigma_i(a_{n-1}) > \sigma_i(a_n)$$, then,
 * if $$\sigma_i(a_{n-2}) < \sigma_i(a_{n-1})$$, then,
 * put $$\min(\sigma_i(a_{n-1}),\sigma_i(a_n))$$ at position $$n-2$$, placing $$\max(\sigma_i(a_{n-1}),\sigma_i(a_n))$$ and $$a_{n-2}$$ at positions $$n-1$$ and $$n$$ in increasing order.

For example, 1234657 follows to 1234576 in the sequence.

Target:

Deduce the method for the general case.

More

 * Robert Sedgewick . Permutation Generation Methods. Computing Surveys, Vol 9, No 2, June 1977, pp. 137-164. http://homepage.math.uiowa.edu/~goodman/22m150.dir/2007/Permutation%20Generation%20Methods.pdf
 * (Lexicographic algorithms: pp. 152ff.)
 * Permutations: sequence A000142 at the OEIS.



RSA (cryptosystem)
RSA (Rivest, Shamir, Adleman, 1978).

Explorations and tools

 * Wolfram|Alpha
 * factordb.com
 * nettle
 * ius/rsatool
 * Understanding Common Factor Attacks: An RSA-Cracking Puzzle
 * Understanding Common Factor Attacks (programming element)
 * RSA Encryptor/Decryptor/Key Generator/Cracker

Programming

 * repl.it

Introduction
There is an operation called closure in the binary relation. The idea of closure is to construct a new binary relation R’of R by adding some ordered pairs, which makes R' have some special properties such as reflexivity, symmetry and transitivity. Transitive closure is an important content of binary relations, which plays an important role in many fields such as the fundamentals of compiling, formal language and automatonundefined.

History
The calculation of transitive closure of binary relation generally according to the definition. This method needs a number of compound set calculation, which is very prone to accidents. In 1962, Warshall proposed an efficient algorithm for computing transitive closures. The Warshall algorithm is simple and easy to implement in the computer, but it uses more time to calculate[2]. In recent years, many scholars proposed improved algorithms of transitive closure. There are algorithms simplify the calculation of the original transitive closure through reducing the number of relation compound[3-4]. Some algorithms use the relational matrices to calculate, also simplifies the calculation of transitive closure[5-6].

Concepts
Let R be the relation on the nonempty set A, relation R’ of A is the transitive closure of R if and only if R’ satisfies: (1) R’ is transitive; (2) R⊆ R’; (3) For any transitive relation R’’ of A include R, there have R’⊆ R’’. We usually use t(R) to represent the transitive closure of R.

State of the art
The transitive closure of a binary relation always exist, any binary relation can be extended until the extended relation is transitive. Besides the transitive closure that we denot here admits a very simple characterization

Practical applications
In Nuutila (1995) we can find useful algoriths to calculate the transitive closure of a graph. Metods are in the worst case faster and reduce the problem to a "simple" matrix multiplication. The problem can be resolved by the Floyd-Warshall algorithm, or by extended search of width-first or depth-first search starting from each node in the graph. Recent research has explored a new efficient methods to calculate a transitive closure in distributes systems based on the MapReduce paradigm (Afrat et al.,2011)

It is a graph analysis algorithm to find the most efficient way to do weighted directed graphics. The Floyd-Warshall algorithm compares all possible paths across the graph between each pair of vertices. It does this by gradually improving an estimate of the shotest path between two vertices, until it is know that the estimate is optimal
 * Floyd-Warshall algorithm:

Introduction
In computer sciences, a union-find algorithm is a data structure that keeps trackof a set of elements partitioned into a number of disjoint subsets.

History
Union-find algorithms were first described by Bernard A. Galler and Michael J. Fischer in 1964. In 1973, their time complexity was bounded to $$\Omega(log^*(n))$$, the iterated logarithm of $$n$$, by Hopcraft and Ulllman. In 1975, Robert Tarjan was the first to prove the $$O(\alpha(n))$$ upper bound on the algorithm's time complexity. In 1989, Fredman and Saks showed that $$\Omega(\alpha(n))$$ words must be accessed by union-find algorithms per operation.

To keep track, know more or write a comment

 * Talk page of the sandbox/workshop of the learning plan 'Discrete and numerical mathematics'.