text:
Topology/Free group and presentation of a group

Free monoid spanned by a set
Let $$V$$ be a vector space and $$v_1,\ldots,v_n$$ be a basis of $$V$$. Given any vector space $$W$$ and any elements $$w_1,\ldots,w_n \in W$$, there is a linear transformation $$\varphi : V \rightarrow W$$ such that $$\forall i \in \{1,\ldots,n\}, \, \varphi(v_i) = w_i$$. One could say that this happens because the elements $$v_1,\ldots,v_n$$ of a basis are not "related" to each other (formally, they are linearly independent). Indeed, if, for example, we had the relation $$v_1 = \lambda v_2$$ for some scalar $$\lambda$$ (and then $$v_1,\ldots,v_n$$ wasn't linearly independent), then the linear transformation $$\varphi$$ could not exist.

Let us consider a similar problem with groups: given a group $$G$$ spanned by a set $$X = \{x_i : i \in I\} \subseteq G$$ and given any group $$H$$ and any set $$Y = \{y_i : i \in I\} \subseteq H$$, does there always exist a group morphism $$\varphi : G \rightarrow H$$ such that $$\forall i \in I, \, \varphi(x_i) = y_i$$? The answer is no. For example, consider the group $$G = \mathbb{Z}_n = \mathbb{Z}/n\mathbb{Z}$$ which is spanned by the set $$X = \{1\}$$, the group $$H = \mathbb{R}$$ (with the adition operation) and the set $$Y = \{2\}$$. If there exists a group morphism $$\varphi : \mathbb{Z}_n \rightarrow \mathbb{R}$$ such that $$\varphi(1) = 2$$, then $$n2 = n \varphi(1) = \varphi(n \, 1) = \varphi(0) = 0$$, which is impossible. But if instead we had choose $$G = \mathbb{Z}$$, then such a group morphism does exist and it would be given by $$\varphi(t) = 2t$$. Indeed, given any group $$H$$ and any $$y \in H$$, we have the group morphism $$\varphi : \mathbb{Z} \rightarrow H$$ defined by $$\varphi(t) = y^t$$ (in multiplicative notation) that verifies $$\varphi(1) = y$$. In a way, we can think that this happens because the elements of the set $$X = \{1\} \subseteq \mathbb{Z}$$ (that spans $$\mathbb{Z}$$) don't verify relations like $$nx = 1$$ (like $$\mathbb{Z}_n$$) or $$xy = yx$$. So, it seems that $$\mathbb{Z}$$ is a group more "free" that $$\mathbb{Z}_n$$.

Our goal in this section will be, given a set $$X$$, build a group spanned by the set $$X$$ such that it will be the most "free" possible, in the sense that it doesn't have to obey relations like $$x^n = 1$$ or $$xy = yx$$. To do so, we begin by constructing a "free" monoid (in the same sense). Informally, this monoid will be the monoid of the words written with the letters of the alphabet $$X$$, where the identity will be the word with no letters (the "empty word"), and the binary operation of the monoid will be concatenation of words. The notation $$x_1 \ldots x_n$$ that we will use for the element of this monoid meets this idea that the elements of this monoid are the words $$x_1 \ldots x_n$$ where $$x_1,\ldots,x_n$$ are letters of the alphabet $$X$$. Here is the definition of this monoid.

Definition Let $$X$$ be a set.
 * 1) We denote the $$n$$-tuples $$(x_1,\ldots,x_n)$$ with $$x_i \in X$$ and $$n \in \mathbb{N}$$ by $$x_1 \ldots x_n$$.
 * 2) We denote $$$$, that is $$(x_1,\ldots,x_n)$$ with $$n = 0$$, by $$1$$.
 * 3) We denote by $$FM(X)$$ the set $$\{x_1 \ldots x_n : n \in \mathbb{N}, x_i \in X\}$$.
 * 4) We define in $$FM(X)$$ the concatenation operation $$*$$ by $$x_1\ldots x_m * y_1\ldots y_n = x_1\ldots x_m y_1\ldots y_n$$.

Next we prove that this monoid is indeed a monoid. It's an easy to prove result, we need to show associativity of $$*$$ and that $$1*x=x*1=x$$.

Proposition $$(FM(X),*)$$ is a monoid with identity $$1$$.

Proof The operation $$*$$ is associative because, given any $$x_1 \ldots x_m,y_1 \ldots y_n,z_1 \ldots z_p \in FM(X)$$, we have

 * $$(x_1 \ldots x_m * y_1 \ldots y_n) * z_1 \ldots z_m$$
 * $$= x_1 \ldots x_m y_1 \ldots y_n * z_1 \ldots z_m$$
 * $$= x_1 \ldots x_m y_1 \ldots y_n z_1 \ldots z_m$$
 * $$= x_1 \ldots x_m * (y_1 \ldots y_n z_1 \ldots z_m)$$
 * $$= x_1 \ldots x_m ( y_1 \ldots y_n * z_1 \ldots z_m)$$.

It's obvious that $$(FM(X),*)$$ has the identity $$1$$ as $$1 * x_1 \ldots x_n = x_1 \ldots x_n$$ by the definition of $$1$$ and $$*$$. $$\square$$

Following the idea that the monoid $$(FM(X),*)$$ is the most "free" monoid spanned by $$X$$, we will call it the free monoid spanned by $$X$$.

Definition ''Let $$X$$ be a set. We denote the free monoid spanned by $$X$$ by $$(FM(X),*)$$.''

Examples
 * 1) Let $$X = \{x\}$$. Then $$FM(X) = \{1,x,xx,xxx,\ldots\}$$ and, for example, $$xx * xxx = xxxxx$$.
 * 2) Let $$X = \{x,y,z\}$$. Then $$1,x,y,z,xxx,yxz,xyzzz \in FM(X)$$ and, for example, $$xxx * yxz = xxxyxz$$.

Free group spanned by a set
Now let us construct the more "free" group spanned by a set $$X$$. Informally, what we will do is insert in the monoid $$FM(X)$$ the inverse elements that are missing in it for it to be a group. In a more precise way, we will have a set $$\bar X$$ equipotent to $$X$$, choose a bijection from $$X$$ to $$\bar X$$ and in this way achieve a "association" between the elements of $$X$$ and the elements of $$\bar X$$. Then we face $$x_1 \ldots x_n \in FM(X)$$ (with $$x_1,\ldots,x_n \in X$$) as having the inverse element $$\overline{x_n} \ldots \overline{x_1}$$ (with $$\overline{x_1},\ldots,\overline{x_n} \in X$$), where $$x_1,\ldots,x_n \in X$$ is is associated with $$\overline{x_1} \ldots \overline{x_n}$$, respectively. Let us note that the order of the elements in $$\overline{x_n} \ldots \overline{x_1}$$ is "reversed" because the inverse of the product $$x_1 \ldots x_n = x_1 * \cdots * x_n$$ must be $$x_n^{-1} * \cdots * x_1^{-1}$$, and the $$x_1^{-1},\ldots,x_n^{-1}$$ are, respectively, $$\overline{x_1},\ldots,\overline{x_n}$$. The way we do that $$\overline{x_n} \ldots \overline{x_1}$$ be the inverse of $$x_1 \ldots x_n$$ is to take a congruence relation $$R$$ that identifies $$x_1 \ldots x_n \overline{x_n} \ldots \overline{x_1}$$ with $$1$$, and pass to the quotient $$FM(X \cup \bar X)$$ by this relation (defining then, in a natural way, the binary operation of the group, $$[u]_R \star [v]_R = [u * v]_R$$). By taking the quotient, we are formalizing the intuitive idea of identifying $$x_1 \ldots x_n \overline{x_n} \ldots \overline{x_1}$$ with $$1$$, because in the quotient we have the equality $$[x_1 \ldots x_n \overline{x_n} \ldots \overline{x_1}]_R = [1]_R$$. Let us give the formal definition.

Definition ''Let $$X$$ be a set. Let us take another set $$\overline{X}$$ equipotent to $$X$$ and disjoint from $$X$$ and let $$f : X \rightarrow \overline{X}$$ be a bijective application.''
 * 1) For each $$x \in X$$ let us denote $$f(x)$$ by $$\bar x$$, for each $$x \in \overline{X}$$ let us denote $$f^{-1}(x)$$ by $$\bar x$$ and for each $$x_1 \ldots x_n \in FM(X \cup \overline{X})$$ let us denote $$\overline{x_n} \ldots \overline{x_1}$$ by $$\overline{x_1 \ldots x_n}$$.
 * 2) Let $$R$$ be the congruence relation of $$FM(X \cup \overline{X})$$ spanned by $$G = \{(u * \bar u,1) : u \in X \cup \overline{X}\}$$, this is, $$R$$ is the intersection of all the congruence relations in $$FM(X \cup \overline{X})$$ wich have $$G$$ as a subset. We denote the quotient set $$FM(X \cup \overline{X})/R$$ by $$FG(X)$$.

Frequently, abusing the notation, we represent an element $$[u]_R \in FG(X)$$ simply by $$u$$.

Because the operation $$[u]_R \star [v]_R = [u * v]_R$$ that we want to define in $$FM(X \cup \bar X)/R$$ is defined using particular represententes $$u$$ and $$v$$ of the equivalence classes $$[u]_R$$ and $$[v]_R$$, a first precaution is to verify that the definition does not depend on the chosen representatives. It's an easy verification.

Lemma ''Let $$X$$ be a set. It is well defined in $$FG(X)$$ the binary operation $$\star$$ by $$[u]_R \star [v]_R = [u_r * v_r]_R$$ (where $$R$$ is the congruence relation of the previous definition).''

Proof Let $$u,u',v,v' \in FM(X)$$ be any elements such that $$[u]_R = [u']_R$$ and $$[v]_R = [v']_R$$, this is, $$uRu'$$ and $$vRv'$$. Because $$R$$ is a congruence relation in $$FM(X \cup \bar X)$$, we have $$u*vRu'*v'$$, this is, $$[u*v]_R = [u'*v']_R$$. $$\square$$

Because the definition is valid, we present it.

Definition ''Let $$X$$ be a set. We define in $$FG(X)$$ the binary operation $$\star$$ by $$[u]_R \star [v]_R = [u_r * v_r]_R$$.''

Finally, we verify that the group that we constructed is indeed a group.

Proposition ''Let $$X$$ be a set. $$(FG(X),\star)$$ is a group with identity $$[1]_R$$ and where $$\forall [u]_R \in FG(X), \, {[u]_R}^{-1} = [\bar u]_R$$.''

Proof
 * 1) $$(FG(X),\star)$$ is associative because $$\forall [u]_R,[v]_R,[w]_R \in FG(X), \, ([u]_R \star [v]_R) \star [w]_R = ([u * v]_R) \star [w]_R = [([u]_R * [v]_R) * w]_R =$$ $$[u * (v * w)]_R = [u]_R \star [v * w]_R = [u]_R \star ([v]_R \star [w]_R).$$
 * 2) Let us see that $$[1]_R$$ is the identity $$(FG(X),\star)$$. Let $$[u]_R \in FG(X)$$ be any element. We have $$[u]_R \star [1]_R = [u * 1]_R = [u]_R$$ and, in the same way, $$[1]_R \star [u]_R = [u]_R$$.
 * 3) Let $$[u]_R \in FG(X)$$ be any element and let us see that $$[u]_R \star [\bar u]_R = [1]_R$$. We have $$[u]_R \star [\bar u]_R = [u * \bar u]_R$$ and, by definition of $$R$$, $$u * \bar u R 1$$, this is, $$[u * \bar u]_R = [1]_R$$, therefore $$[u]_R \star [\bar u]_R  = [1]_R$$ and, in the same way, $$[\bar u]_R \star [u]_R = [1]_R$$. $$\square$$

In the same way that we did with the free monoid, we will call free group spanned by the set $$X$$ to the more "free" group spanned by this set.

Definition ''Let $$X$$ be a set. We call free group spanned by $$X$$ to $$(FG(X),\star)$$.''

Example Let $$X = \{x\}$$. Let us choose any set $$\bar X = \{y\}$$ disjoint (and equipotent) of $$X$$. Let $$f : X \rightarrow \bar X$$ be any (in fact, the only) bijective application of $$X$$ in $$\bar X$$. Then we denote $$f(x) = y$$ by $$\bar x$$ and we denote $$f^{-1}(y) = x$$ by $$\bar y$$. We regard $$x$$ and $$y$$ as inverse elements. Let $$R$$ be the congruence relation of $$FM(X \cup \bar X)$$ spanned by $$G = \{(1,1),(x \bar x,1),(xx \bar x \bar x,1),\ldots\}$$. $$FG(X) = FM(\{x,\bar x\})/R$$ is the set of all "words" written in the alphabet $$\{[x]_R,[\bar x]_R\}$$. For example, $$[1]_R,[x]_R,[\bar x]_R, [xx\bar x xx]_R \in FG(X)$$.

We have $$G \subseteq R$$ and, for example, $$(xx \bar x,1) \in R$$, because $$(x\bar x,1) \in G \subseteq R$$ (therefore $$x \bar x R 1$$) and because $$R$$ is a congruence relation, we can "multiply" both "members" of the relation $$x \bar x R 1$$ by $$x$$ and obtain $$xx \bar x R x$$. We see $$x \bar x R 1$$ as meaning that in $$FG(X)$$ We have $$xx \bar x = x$$ (more precisely, $$[xx \bar x]_R = [x]_R$$), and we think in this equality as being the result of one $$x$$ "cut out" with $$\bar x$$ in $$xx \bar x$$.

Given $$u \in FM(X \cup \bar X)$$, let us denote the exact number of times that the "letter" $$x$$ appears in $$u$$ by $$|u|_x$$ and let us denote the exact number of times the "letter" $$\bar x$$ appears in $$u$$ by $$|u|_\bar x$$. Then "cutting" $$x$$'s with $$\bar x$$'s it remains a reduced word word with $$|u|_x - |u|_\bar x$$ times the letter $$x$$ (if $$|u|_x - |u|_\bar x < 0$$, let us us consider that there aren't any letters $$x$$ and remains $$-(|u|_x - |u|_\bar x)$$ times the letter $$\bar x$$). Let us denote $$|u|_x - |u|_\bar x$$ by $$|u|_{x - \bar x}$$. We have In this way, each element $$[u]_R \in FG(X)$$ is determined by the integer number $$|u|_{x - \bar x}$$ and the product $$\star$$ of two elements $$[u]_R,[v]_R \in FG(X)$$ correspondent to the sum of they associated integers numbers $$|u|_{x - \bar x}$$ and $$|v|_{x - \bar x}$$. Therefore, it seems that the group $$(FG(X),\star)$$ is "similar" to $$(\mathbb{Z},+)$$. indeed $$(FG(X),\star)$$ is isomorph to $$(\mathbb{Z},+)$$ and the application $$|\cdot|_{x - \bar x} : FG(X) \rightarrow \mathbb{Z}$$ is a group isomorphism.
 * 1) $$[u]_R = [v]_R$$ if and only if $$|u|_{x - \bar x} = |v|_{x - \bar x}$$ and
 * 2) $$\forall [u]_R,[v]_R \in FG(X), \, |uv|_{x - \bar x} = |u|_{x - \bar x} + |v|_{x - \bar x}$$.

Presentation of a group
Informally, it seems that $$\mathbb{Z}_n$$ is obtained from the "free" group $$\mathbb{Z}$$ imposing the relation $$nx = 1$$. Let us try formalize this idea. We start with a set $$X$$ that spans a group $$G$$ that que want to create and a set of relations $$R$$ (such as $$x^n = 1$$ or $$xy = yz$$) that the elements of $$G$$ must verify and we obtain a group $$G/R$$ spanned by $$G$$ and that verify the relations of $$R$$. More precisely, we write each relation $$u = v$$ in the form $$uv^{-1} = 1$$ (for example, $$xy = yx$$ is written in the form $$xyx^{-1}y^{-1} = 1$$) and we see each $$uv^{-1}$$ as a "word" of $$FG(X)$$. Because $$R$$ doesn't have to be a normal subgroup of $$G$$, we can not consider the quotient $$FG(X)/R$$, so we consider the quotient $$FG(X)/N$$ where $$N$$ is the normal subgroup of $$FG(X)$$ spanned by $$R$$. In $$G/N$$, we will have $$uv^{-1}N = 1N$$, which we see as meaning that in $$G/N$$ the elements $$uv^{-1}$$ and $$1$$ are the same. In this way, $$FG(X)/N$$ will verify all the relations that we want and will be spanned by $$X$$ (more precisely, by $$\{xN : x \in X\}$$). Let us formalize this idea.

Definition ''Let $$G$$ be a group. We call presentation of $$G$$, and denote by $$< X:R >$$, to a ordered pair $$(X,R)$$ where $$X$$ is a set, $$R \subseteq FG(X)$$ and $$G \simeq FG(X)/N$$, where $$N$$ is the normal subgroup of $$FG(X)$$ spanned by $$R$$. Given a presentation $$$$, we call spanning set to $$X$$ and set of relations to $$R$$.''

Let us see some examples of presentations of the free group $$FG(X)$$ and the groups $$\mathbb{Z}_n$$, $$\mathbb{Z} \oplus \mathbb{Z}$$, $$\mathbb{Z}_m \oplus \mathbb{Z}_n$$ and $$S_3$$. We also use the examples to present some common notation and to show that a presentation of a group does not need to be unique.

Examples
 * 1) Let $$X$$ be a set. $$$$ is a presentation of $$FG(X)$$ because $$FG(X) \simeq FG(X)/\{1\}$$, where $$\{1\}$$ is the normal subgroup of $$FG(X)$$ spanned by $$\emptyset$$. In particular, $$<\{x\}:\emptyset >$$ is a presentation of $$(\mathbb{Z},+) \simeq FG(\{x\})$$, more commonly denoted by $$$$. Another presentation of $$(\mathbb{Z},+)$$ is $$<\{x,y\}:\{xy^{-1}\}>$$, more commonly denoted by $$$$. Informally, in the presentation $$$$ we insert a new element $$y$$ in the spanning set, but we impose the relation $$xy^{-1} = 1$$, this is, $$x = y$$, which is the same as having not introduced the element $$y$$ and have stayed by the presentation $$$$.
 * 2) Let $$X = \{x\}$$. $$$$ (where $$x^n = x \star \cdots \star x \in FG(X)$$ $$n$$ times) is a presentation of $$\mathbb{Z}_n$$. Indeed, the subgroup of $$FG(X)$$ spanned by $$\{x^n\}$$ is $$N = \{\ldots,\bar{x}^{2n},\bar{x}^n,1,x^n,x^{2n},\ldots\} \simeq n\mathbb{Z}$$ and $$FG(X) \simeq \mathbb{Z}$$, therefore$$\mathbb{Z}_n = \mathbb{Z}/n\mathbb{Z} \simeq FG(X)/N$$. Is more common to denote $$<\{x\} : \{x^n\}>$$ by $$$$.
 * 3) Let $$X = \{x,y\}$$ (with $$x$$ and $$y$$ distinct) and $$R = \{xyx^{-1}y^{-1}\}$$. $$$$ is a presentation of $$\mathbb{Z} \oplus \mathbb{Z}$$. Informally, what we do is impose comutatibility in $$FG(X)$$, this is, $$xy = yx$$, this is, $$xyx^{-1}y^{-1} = 1$$, obtaining a group isomorph to $$\mathbb{Z} \oplus \mathbb{Z}$$. It's more usually denote $$<\{x,y\} : \{xyx^{-1}y^{-1}\}>$$ by $$$$.
 * 4) Let $$X = \{x,y\}$$ and $$R = \{xyx^{-1}y^{-1},x^m,y^n\}$$. $$$$ is a presentation of $$\mathbb{Z}_m \times \mathbb{Z}_n$$. Informally, what we do is impose commutability in the same way as in the previous example, and we impose $$x^m = 1$$ and $$x^n = 1$$ to obtain $$\mathbb{Z}_m \times \mathbb{Z}_n$$ instead $$\mathbb{Z} \oplus \mathbb{Z}$$. It's more common denote$$<\{x,y\}:\{xyx^{-1}y^{-1},x^m,y^n\}>$$ by $$$$.
 * 5) $$<\{a,b,c\}:\{aa,bb,cc,abac,cbab\}>$$, more commonly written $$$$, is a presentation of $$S_3$$, the group of the permutations of $$\{1,2,3\}$$ with the composition of applications. To verify this, one can verify that any group with presentation $$$$ as exactly six elements $$id$$, $$a$$, $$b$$, $$c$$, $$a$$, $$ab$$ and $$ac$$, and that the multiplication of this elements results in the following Cayley table that is equal to the Cayley table of $$S_3$$. Just to give an idea how this can be achieved, a group with presentation $$$$ as exactly the elements $$id$$, $$a$$, $$b$$, $$c$$, $$a$$, $$ab$$ and $$ac$$ because none of this elements are the same (the relations $$a^2 = b^2 = c^2 = abac = cbab = 1$$ don't allow us to conclude that two of the elements are equal) and because "another" elements like $$bc$$ are actually one of the previous elements (for example, from $$cbab = id$$ we have $$cb = ab$$, and taking inverses of both members, we have $$b^{-1}c^{-1} = b^{-1} a^{-1}$$, which, using $$a^2 = b^2 = c^2 = id$$, this is, $$a = a^{-1}$$, $$b = b^{-1}$$ and $$c = c^{-1}$$, results in $$bc = ba$$). Then, using the relations of the presentation, one can compute the Cayley table. For example, $$a (ab) = b$$ because we have the relation $$a^2 = 1$$. Another example: we have $$b(ac) = a$$ because we can multiply both members of the relation $$abac = id$$ by $$a$$ and then use $$a^2 = id$$. One could have suspected of this presentation by taking $$a = (1 \ 2)$$, $$b = (1 \ 3)$$ and $$c = (2 \ 3)$$ and then, trying to construct the Cayley table of $$S_3$$, found out that it was possible if one know that $$a^2 = b^2 = c^2 = abac = cbab = 1$$.

It's natural to ask if all groups have a presentation. The following theorem tell us that the answer is yes, and it give us a presentation.

Theorem Let $$(G,\times)$$ be a group.
 * 1) The application $$\varphi : FG(G) \rightarrow G$$ defined by $$\varphi([x_1]_R \star \cdots \star [x_n]_R) = x_1 \times \cdots \times x_n$$ (where $$x_1,\ldots,x_n \in G$$) is an epimorphism of groups.
 * 2) $$$$ is a presentation of $$(G,\times)$$.

Proof
 * 1) $$\varphi$$ is well defined because every element of $$FG(X)$$ as a unique representations in the form $$[x_n] \star \cdots [x_n]_R$$ with $$x_1,\ldots,x_n \in G$$, with the exception of $$[1]_R$$ appears several times in the representation, but that doesn't affect the value of $$x_1 \times \cdots \times x_n$$ Let $$[x_1]_R \star \cdots \star [x_m]_R,[y_1]_R \star \cdots \star [y_n]_R \in FG(X)$$ be any elements, where $$x_1,\ldots,x_m,y_1,\ldots,y_n \in G$$. We have $$\varphi(([x_1]_R \star \cdots \star [x_m]_R) \star ([y_1]_R \star \cdots \star [y_n]_R)) = (x_1 \times \cdots \times x_m) \times (y_1 \times \cdots \times y_n) =$$ $$\varphi([x_1]_R \star \cdots \star [x_m]_R) \times \varphi([y_1]_R \star \cdots \star [y_n]_R)$$, therefore $$\varphi$$ is a morphism of groups. Because $$\forall x \in G, \, \varphi ([x]_R) = x$$, then $$G$$ is a epimorphism of groups.
 * 2) Using the first isomorphism theorem (for groups), we have $$FG(G)/\textrm{ker} \, \varphi \simeq \varphi(G) = G$$, therefore $$<G:\textrm{ker} \, \varphi>$$ is a presentation of $$(G,\times)$$. $$\square$$

The previous theorem, despite giving us a presentations of the group $$G$$, doesn't give us a "good" presentation, because the spanning set $$G$$ is usually much larger that other spanning sets, and the set of relations $$\mathrm{ker} \, \varphi$$ is also usually much larger then other sufficient sets of relations (it is even a normal subgroup of $$FG(G)$$, when it would be enough that it span an appropriated normal subgroup).


text:
User:Beland

See Wikipedia:User:Beland.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

title: User:Beland


text:
Talk:Console Game Programming

I think the "emulated"/"actual" console categories are kind of silly, in that all are "actual" consoles, and all will probably be emulated at some point, and in fact emulators already exist for the Playstation, Game Cube, and Dreamcast. Maybe a chronological/alphabetical list would be better?

Joe Lee 22:29, 30 May 2005 (UTC)

title: Talk:Console Game Programming


text:
User:Messi~enwikibooks

messi (de.wikipedia)

[Message] [E-mail]

title: User:Messi~enwikibooks


text:
QBasic/Advanced Input

INKEY$
Getting real time information from the user is a little more difficult. To do so, we will use the INKEY$ command, which checks to see whether a user typed a key and provides the keypress to the program.

Look at this code and then we will look at it in depth:

The first part is the DO-LOOP which constantly polls INKEY$ for a return value. In the basic use, INKEY$ returns an empty string if no keys are being pressed and continues with the program. Once a key is pressed, INKEY$ will return that key immediately.

The keyboard buffer
What is INKEY$ doing and how does it work?

While the INKEY$ command looks like it returns the key currently being pressed, this is not the case. It is used by the program to answer the question, "What is IN the KEYboard buffer?" To understand this you will need to understand what a basic buffer is and why it is used.

In older systems (not necessarily the IBM PC) a single chip processed keyboard input, and controlled the LED lights for caps lock and number lock. Because a computer does many things at once (e.g., take input from the mouse, crunch numbers, call subroutines, display new information on the screen), it needs to be able to remember what was pressed on the keyboard while it is busy. This chip contained some memory (called a buffer) that allow keeping track of a limited number of keypresses.

Within the Dos platform under IBM PCs, the hardware has changed slightly. Instead of a hardware buffer, pressing or releasing a key will interrupt the running program to add a keystroke to a software buffer located in the BIOS. This procedure is usually unnoticed by the user and has minimal impact on system performance. However, this buffer allows for 15 characters: attempting to overflow it when the computer is busy will cause a short beep and drop any further characters.

The INKEY$ command uses this buffer as a FIFO (First In First Out) buffer. As an example let's say you have a game that has a bouncing ball on the screen and a paddle at the bottom. The computer program constantly has to update the screen to show the movement of the ball. While it does this the program passes by an INKEY$ command to see what value is returned. If the user has pressed a key since the last time the command was invoked it will return that key. Let's say the ball is moving over to the right and the user needs to press the "R" key to tell the program to move the paddle right. Since the program is busy moving the ball and updating the screen, it does not instantaneously notice that the user has pressed the key. Instead, the key press is stored in the keyboard buffer, and retrieved a few milliseconds (or microseconds) later when the INKEY$ command is used.

In many programs (as above), INKEY$ will appear nested in a loop. It is requested over and over again. This allows the program to get user input one character at a time. Using our example above, the user may need to press R over and over again until the paddle is under the ball. On the other hand, the user may press R too many times and need to press L to move it left. Because the INKEY$ command is using a FIFO buffer it will always retrieve the keys pressed in the same order as they were typed.

In summary, the INKEY$ command will always return and remove the first character in the keyboard buffer. Generally speaking, it is used over and over to retrieve every key that has been pressed, and to allow a user to interact with a program in a close approximation to "real time." If there is no key in the keyboard buffer, INKEY$ returns an empty string (no character).

Scancodes
Some keypresses are not associated with an ASCII character. When one of these keys is pressed, INKEY$ returns a string with two characters: the first character is a null (ASCII code 0), and the second is the raw scan code for the keyboard. A full listing of the scancodes can be found within the QBASIC help file. You can also determine the scan codes by examining the results of INKEY$ as you press those keys in question.

Ctrl+           Extended; prefixed with CHR$(0) 1 A               3   Ctrl+2 2 B              15   Shift+Tab 3 C                4  D                Alt+    Alt+    Alt+     Alt+ 5 E              16  Q   30  A   44  Z   120  1 6 F              17  W   31  S   45  X   121  2 7 G              18  E   32  D   46  C   122  3 8 H  Backspace   19  R   33  F   47  V   123  4 9 I  Tab         20  T   34  G   48  B   124  5 10 J  Ctrl+Enter  21  Y   35  H   49  N   125  6 11 K              22  U   36  J   50  M   126  7 12 L              23  I   37  K           127  8 13 M  Enter       24  O   38  L           128  9 14 N              25  P                   129  0 15 O                                      130  - 16 P                 Shift Ctrl Alt       131  = 17 Q              59   84   94  104  F1 18  R              60   85   95  105  F2 19  S              61   86   96  106  F3 20  T              62   87   97  107  F4 21  U              63   88   98  108  F5 22  V              64   89   99  109  F6 23  W              65   90  100  110  F7 24  X              66   91  101  111  F8 25  Y              67   92  102  112  F9 26  Z              68   93  103  113  F10 27 [  Escape     133  135  137  139  F11 28 \             134  136  138  140  F12 29 ] 30  6              71  Home   72  Up    73  PgUp 31 -              75  Left             77  Right 79 End    80  Down  81  PgDn Ctrl+          82  Insert           83  Del 127 Backspace 119 Ctrl+Home   132  Ctrl+PgUp 115 Ctrl+Left   116  Ctrl+Right 117 Ctrl+End    118  Ctrl+PgDn

title: QBasic/Advanced Input


text:
Talk:Italian/Vocabulary/Basic Words and Phrases

Untitled
la vespa e pieno - the wasp is full


text:
Portuguese/Contents/L1/Lesson Three - What Are You Going To Do?

Return to Portuguese – Return to Contents – Go to Lesson Four

In this dialogue João and Ricardo are talking about what they are going to do. What day? Well, let's have a look at the days of the week before we go any further.

Note: If it's clear that you are talking about days of the week, you don't actually have to say 'feira'.

So Ricardo says

Ricardo: Olá. O que vai fazer no sábado?

Olá of course means 'hello'.

O que você vai fazer (no sábado) ?

This is a very useful phrase that basically means 'What are you going to do (on Saturday)?' You can of course replace the 'sábado' with whichever day you want to use. 'No' is a contraction of 'em' (in) and 'o' ('the', masculine). Weekend days are masculine, whereas week days are feminine, so you'll say 'no domingo' (on Sunday) but 'na segunda(-feira)' (on Monday).

The answer will be something along the lines of:

(Eu) vou (fazer, nadar, comer)

This means 'I am going'. 'Vou' is one part of the word 'ir' which means 'to go' in Portuguese. Just like in English, we say what we will do by saying 'going to', in Portuguese we can use the verb 'ir' (which, as a verb, changes for each person that it refers to, like 'estar' and 'ser') to talk about the future. First we need to look at how to conjugate (change for each person) the verb 'ir'. Remember the tree analogy? 'Ir' is called the infinitive - the trunk - of the verb. We can't just simply use it, we have to change it.

IR - Present Indicative Tense Eu vou - I go Tu vais - You (familiar) go Você vai - You (informal) go Ele/Ela vai  - He/She goes Nós vamos - We go Vocês vão - You (plural) go Eles/Elas vão - They (group of males or mixed) / They (group of females) go

You need to memorize the conjugations for this verb because it is IRREGULAR - it has no pattern to it.

You may also recognize a word from the dialogue. Ricardo asked João,

Como vai? - How are you doing (literally "How are you going?")

This is another way to ask how someone is. Do you remember Como está? from the first lesson? Remember that como means "how". So como vai? literally means "How are you going?". It can be replied to exactly like "Como está".

Now that we know how this verb conjugates for every person, we can use it to say what someone is going to do.

Of course you can use any of the conjugations we have learned, not just eu vou and Nós vamos.

Try out the following exercise

The infinitive forms of verbs - like gostar, ser and ir - are used quite a bit in Portuguese - but usually only when there is another verb before them. For instance, we know that we use the infinitive after the verb 'ir'. We also know how to say "I like something". But how do we say "I like to do something"? This is nearly as simple as saying "I am going to do something". Except here we use the verb gostar (remember, this means to like) instead of ir - and we slip the word de in as well.

Return to Portuguese – Return to Contents – Go to Lesson Four

de:Portugiesisch: Lektionen: Was machen wir?


text:
Talk:Portuguese/Contents/L1/Lesson Seven - What Time Is It?

Untitled
If someone ends up doing thing this page; please only introduce numbers up to twenty...the other will come later on.

Error
I think this is wrong f)São vinte para as quatro. is labled as 4:40. Whereas what the portuguese phrase says is vinte (twenty) to (quatro) four

 * It should be f)São vinte para as cinco. 152.78.126.18 18:12, 11 May 2007 (UTC)


text: User:Kmk~enwikibooks

title: User:Kmk~enwikibooks


text:
User:Ramir

ru:Участник:Ramir

title: User:Ramir


text:
The Linux Kernel/Softdog Driver

A watchdog timer is a device that triggers a system reset if it detects that the system has hung. A program running on the system is supposed periodically to service the watchdog timer by writing a "service pulse." If the watchdog is not serviced within a particular period of time, the watchdog assumes that the system has hung, and triggers a system reset.

Usually, watchdog timers are implemented as add-on cards, or as on-chip peripherals within microcontrollers. But if there is no hardware watchdog, the Linux kernel can provide a software watchdog implemented using kernel timers.

In Linux, the watchdog driver provides a character driver interface to the user space. When some data is written to the watchdog driver, the watchdog driver services the watchdog hardware. The user space application periodically writes some data to the watchdog driver, depending upon the watchdog timeout period. If for some reason the user space application hangs, the watchdog device does not get serviced and hence triggers a system reset.

Usually the application that writes to the watchdog driver is a watchdog daemon which monitors processes in the system, as well as other parameters such as CPU utilization, memory utilization, and so on.

When the softdog driver is opened, softdog schedules a kernel timer to expire after a specified timer margin. When some data is written to the driver, the softdog driver re-schedules the timer. The user space watchdog daemon periodically writes to the driver, and the timer is continuously rescheduled and hence the timer callback is never called. If the watchdog daemon stops writing to the driver, the timer expires and the callback is called. In the timer callback, the system is restarted.

⚲ API:

👁 Example:

📚 References:
 * Embedded Systems/Watchdog Timer
 * Embedded Systems/Watchdog Timer

title: The Linux Kernel/Softdog Driver


text:
User talk:Amuhr86~enwikibooks

Hey everyone I'm just a newcomer but I'm really excited to see if I can contribute!

wikiversity
If you cast a wikiversity vote, please make a link at your Wikimedia meta-wiki user page linking back to your wikibooks user page. If you do not do so, your vote will not count. --JWSurf 02:55, 5 October 2005 (UTC)

Your account will be renamed
Hello,

The developer team at Wikimedia is making some changes to how accounts work, as part of our on-going efforts to provide new and better tools for our users like cross-wiki notifications. These changes will mean you have the same account name everywhere. This will let us give you new features that will help you edit and discuss better, and allow more flexible user permissions for tools. One of the side-effects of this is that user accounts will now have to be unique across all 900 Wikimedia wikis. See the announcement for more information.

Unfortunately, your account clashes with another account also called Amuhr86. To make sure that both of you can use all Wikimedia projects in future, we have reserved the name Amuhr86~enwikibooks that only you will have. If you like it, you don't have to do anything. If you do not like it, you can pick out a different name.

Your account will still work as before, and you will be credited for all your edits made so far, but you will have to use the new account name when you log in.

Sorry for the inconvenience.

Yours, Keegan Peterzell Community Liaison, Wikimedia Foundation 22:57, 17 March 2015 (UTC)

Renamed
 This account has been renamed as part of single-user login finalisation. If you own this account you can |log in using your previous username and password for more information. If you do not like this account's new name, you can choose your own using this form after logging in: . -- Keegan (WMF) (talk) 04:31, 19 April 2015 (UTC)

title: User talk:Amuhr86~enwikibooks


text:
Smalltalk Programming/Overview

removeEventsTriggeredFor: anObject inState: aState "Remove all the events triggered by the receiver which would have	been sent to anObject in the given state."

| events | events := transitions at: aState ifAbsent: [ ^self ]. events copy keysAndValuesDo: [:evtSym :msgSendSet | | newSet | newSet := msgSendSet reject: [:each | each receiver == anObject and: [ (anObject == self and: [ each selector == #newState: ]) not ] ]. msgSendSet size = newSet size ifFalse: [newSet isEmpty ifTrue: [ events removeKey: evtSym] ifFalse: [ events at: evtSym put: newSet]]].

Claim: Lots of indentions is a sign that code needs to be refactored. CPS

title: Smalltalk Programming/Overview


text:
Cookbook:Sunflower

The sunflower plant is a food plant that produces large and showy flowers.

 * sunflower seed
 * sunchoke
 * sunflower oil

title: Cookbook:Sunflower


text:
Cookbook:Boiled Custard

Boiled custard is a classic dessert, with a light texture and a mild flavor. This recipe is for "boiled" custard, but ironically, as Mrs. F.L. Gillette said in The Whitehouse Cookbook, "it must not boil or it will curdle." See more on custard in general here.

Ingredients

 * 2 cups (500 g / 1.1 pint) milk
 * 2 eggs
 * ¼–½ cup (55–110 g / 1.9–3.9 oz) white granulated sugar
 * 1 teaspoon vanilla extract
 * 1 pinch salt (optional)
 * 1 tablespoon cornstarch (optional)
 * 2 tablespoons water (optional)

Procedure

 * 1) Heat milk and salt (if using) in a double boiler until bubbles form around the edges.
 * 2) Beat eggs with sugar until uniform.
 * 3) Gradually mix approximately ½ cup (125 ml / 4.2 oz) hot milk into the egg mixture to temper it.
 * 4) Slowly stir egg mixture into remaining hot milk.
 * 5) Optionally, mix cornstarch and water and stir into custard.
 * 6) Stir over heat until thickened (should coat the spoon), without bringing to a boil.
 * 7) Remove from heat, and continue stirring to dry the custard slightly.
 * 8) Stir in vanilla before the dish has cooled completely.
 * 9) Serve warm or chilled.

Notes, tips, and variations

 * Replace vanilla extract with almond or maple extract, brandy or grated lemon zest.
 * Caramel custard: stir ½ cup 110 g / 3.9 oz) of sugar in a small pan until it becomes liquid and just begins to smoke. Stir it into the hot milk before adding the egg mixture.

title: Cookbook:Boiled Custard


text:
Cookbook:Quiche

| Cuisine of France

A quiche is a baked, unsweetened custard pie, often made with savory fillings. Originally served in Germany, quiche was adopted by neighboring France and is now considered a traditional French dish. The French (and now English) word quiche comes from a dialectal form (Küchle) of the German word for cake (Kuchen). Quiche became popular in Britain after World War II and in the United States during the 1960s and 70s.

Ingredients

 * 5 eggs
 * 1 ⅓ cup (320 ml) cream (approximately 30% fat)
 * 1 teaspoon chopped fresh tarragon
 * 1 dash ground nutmeg
 * ¼ teaspoon salt
 * ⅛ teaspoon ground pepper
 * 1 prepared frozen pie crust
 * ¾ cup (180 ml) freshly-grated Swiss cheese

Procedure

 * 1) Preheat oven to 375°F (190°C).
 * 2) Place the eggs, cream, tarragon, nutmeg, salt, and pepper in a blender; blend as briefly as possible until they form a homogeneous mixture.
 * 3) In the pie crust, create alternating layers of the shredded cheese and the mixture from the blender until the crust is full.
 * 4) Bake the quiche for 35–40 minutes; a toothpick or fork inserted into its middle should come out "clean".
 * 5) Remove the quiche from the oven, and let it cool for at least 20 minutes before serving.

Notes, tips, and variations

 * Use nutmeg sparingly.
 * Fresh tarragon will be better than dried tarragon.
 * Placing a very hot pan in under the quiche will give it greater volume.
 * Try making quiches with sautéed onions, sautéed broccoli, and shredded sharp cheddar cheese; feel free to experiment.

Warnings

 * The quiche mixture may drip over the edge of the pie crust while cooking; place it on a cookie sheet or place foil on the oven rack below it.
 * The quiche will continue to cook after it is removed from the oven; be careful not to overcook it or cut it before it has had a chance to set.
 * Half-and-half (cream with approximately 12% fat) can be substituted for regular cream to make this dish less fattening; however, be cautious of using milk because low-fat dairy products curdle more easily.

Livre de cuisine/Quiche lorraine

title: Cookbook:Quiche


text:
User:Joe Jarvis~enwikibooks

Hello. If you have a comment for me, please edit my talk page. Thanks.

—Joe Jarvis

title: User:Joe Jarvis~enwikibooks


text:
Radiation Oncology/Bladder

Bladder Cancer
 * Staging
 * Overview
 * Superficial bladder cancer
 * Muscle-invasive bladder cancer
 * RT Technique
 * RTOG bladder trials
 * Randomized evidence
 * Official guidelines

title: Radiation Oncology/Bladder


text:
Wikibooks:Book of the month/July 2005 voting

The voting for the Book of the month for July 2005 is open from 1 - 30 June, 2005, and will close on June 30, 2005, 00:00 UTC. The book of the month will be featured on the main page of Wikibooks.

'''Closed. Any votes added will be reverted.'''

Wikijunior Solar System (4)
(Automaticly nominated with 4 votes in May.) vote:

 * 1) 159753 19:05, 2 Jun 2005 (UTC)
 * 2) Rob Horning 00:08, 8 Jun 2005 (UTC)
 * 3) Klingoncowboy4 Saturday June, 25, 2005 7:23 (UTC)
 * 4) Serge Thursday 22:22, Jun 30, 2005 (UTC)

comments:

Blender 3D/Noob to Pro (5)
vote:

 * 1) Reub2000 11:58, 3 Jun 2005 (UTC)
 * 2) Spiderworm 12:37, 9 Jun 2005 (UTC)
 * 3) Linuxlizzard 14:02, 13 Jun 2005 (UTC)
 * 4) Nyr14 00:15, 18 Jun 2005 (UTC)
 * 5) MeMoria 16:06, 28 Jun 2005 (UTC)

comments:

 * It's ok for me to vote for my own book, right? Anyways, the book has been very beneficial to Blender hopefuls, and it is listed first above all the other tutorials on the official Blender 3D site ( see http://blender3d.org/cms/Tutorials.243.0.html ).  I get emails all the time thanking me for putting this together:

"Thanks for your time and effort on the Blender guide on WikiBooks. I've used many 3d packages(Maya, 3ds) but have wanted better understanding,.. quickly of Blender. Your guide has been instrumental in this act, and in several hours I'm really starting to get a feel for what Bender is capable of."

"Im completely new to 3D imaging on the computer. Your tutorial was clear and easily understood. Just at the right level for me, explaining the basics without being patronising. Perfect, Thanks."

... and so my (obviously biased) vote goes to Blender 3D/Noob to Pro. --Spiderworm 12:37, 9 Jun 2005 (UTC)

 * Yes! This is a great book. I've tried using the so-called "manual" for B3D but this is a lot easier to use. MeMoria 16:06, 28 Jun 2005 (UTC)

London (3)
vote:

 * 1) Charlie123 13:24, 8 Jun 2005 (UTC)
 * 2) Starfish77 14:16, 8 Jun 2005 (UTC)
 * 3) Starandstripe 12:48, 16 Jun 2005 (UTC)
 * 4) Sockpuppet3 18:16, 16 Jun 2005 (UTC)

comments:

 * This book is growing every day, and it's the first travel guide to feature on Wikibooks.
 * yeah c what u mean. could do wiv more content tho' Dave 19:06, 8 Jun 2005 (UTC)
 * It is certainly good to have a travel guide on WB...why didn't we think of this before?
 * Wow! Yeah!, this book is awesome! Great idea! Sockpuppet3 18:16, 16 Jun 2005
 * Looks pre-alpha to me. Reub2000 20:14, 18 Jun 2005 (UTC)
 * Thank you! If you actually look at this Wikibook, you can read totally through it in about 3 minutes. I can't see how four actual people could have honestly voted for this when all the other nominations are so much more deserving. While I admit to being a sockpuppet, I think Starandstripe and Starfish77 need to admit to it too. For both, their first (and sometimes only) edits were votes and praise for this contentless Wikibook. --Sockpuppet3 12:39, 19 Jun 2005 (UTC)
 * I think I'll have to agree with Sockpuppet3. He does look like the third sockpuppet. Not only are Starfish77's and Starandstripe's contributions only their votes, but Starfish77's vote came just four minutes after Charlie123's (the primary author) last edit of the day--a comment giving further praise to his book. --Everlong 18:36, 19 Jun 2005 (UTC)
 * Even if he did register multiple accounts, the rules say that any logged in user can vote. Maybe the rules should be changed so that only users with at least 100 edits can vote? Reub2000 22:38, 19 Jun 2005 (UTC)

 * Sorry about that. Maybe it would be better as a contribution of the month? Charlie123 15:50, 23 Jun 2005 (UTC)

Mandarin Chinese (3)
vote:

 * 1) Everlong 07:11, 13 Jun 2005 (UTC)
 * 2) Klingoncowboy4 03:20, 26 Jun 2005 (UTC)
 * 3) Destrogal 18:45, 30 Jun 2005 (UTC)

comments:

 * I know Andreas and others have been voting for us these last few months, but before I just couldn't call us ready--our pronunciation guide especially being a big stumbling block. Lately I've made a number of additions and rewrites to make the intro lessons more beginner-friendly and I'll continue so that by the end of this month we'll have something really good. We're ready. --Everlong

Programming:C -/- -/- (3)
vote:

 * 1) Eyu100 18:35, 20 Jun 2005 (UTC)
 * 2) WB 23:34, 23 Jun 2005 (UTC)
 * 3) Klingoncowboy4 03:19, 26 Jun 2005 (UTC)

comments:


text:
Demystifying Depression

This book may not have been written by a doctor. The recommendations are not referenced to actual research except in a bibliography. This document should in no way serve as a substitute for medical advice. Experts are welcome to add their comments at Talk:Demystifying Depression.

"Depression is a mood disorder", so start many descriptions of the illness. That is a gross understatement. Depression does indeed seriously affect your mood, but that is just the tip of the iceberg. A clinical depression can be an incapacitating illness, affecting your ability to perform tasks that require concentration and rendering you unable to work.

By writing this document we hope to provide you with the knowledge everyone should have about their mental well-being. Depression is not an unavoidable fate. It is physical.

The good news is that you can recover and yes, even learn to be happier than you have ever been before.

Download the entire book as a PDF File. This can be done in two ways, you can either right click on the link "PDF File Edition 1.0" and choose "Save target as", this saves the PDF on your computer for viewing at any time; alternatively left click on the link: PDF File Edition 1.0 Click here to see a continuous, printable version of the book /Print version/ ( [ edit] )

Table of Contents

 * /Introduction/
 * What is Depression?
 * Normal Neuron Communication: The Role of Serotonin
 * The Stress System: Adrenaline and Cortisol
 * /The Buildup to a Depression/
 * /Speculation on the Physiology of Depression/
 * The Recovery Process
 * Recovery Guide
 * /General Lifestyle Advice/
 * /Daily Routine/
 * /Tips for Good Sleep/
 * /The Controversy about Antidepressants/
 * /Suicide/
 * /The Role of Sports/
 * /Feeling Good vs Actual Improvement/
 * /Why Moderate Exercise May Sometimes Help/
 * /Caveats of Treating Depression with Exercise/
 * /A Real World Example/
 * /Depression and Ageing/
 * The Genetic Link
 * Is Depression on the Rise?
 * /Quantifying Depression/
 * /The Burnout Syndrome/
 * /Happiness/
 * /Facing the Prejudice/
 * /Conclusion/
 * /References/
 * /List of Figures/

Colophon
This book is based on a two-part series with the same title published on Kuro5hin by Name of Feather. Below you will find links to the original articles plus the associated discussions.

 * Demystifying Depression - Part I (via Internet Archive)
 * Demystifying Depression - Part II (via Internet Archive)

title: Demystifying Depression


text:
Demystifying Depression/Introduction

Introduction
In order to begin any explanation of the nature of depression, it is advisable to begin by establishing some common terms, distinctions, and popular definitions. But most of all what must be stressed are the meanings and differences between them.

The volume of misconceptions, stereotypes and prejudices that the vast majority of people have concerning the topic of depression in the medical sense is truly astounding.

To begin, we must make a very clear distinction between Depression and Clinical/Bipolar Depression. Colloquially, they are used indiscriminately.

Anyone who has experienced Clinical/Bipolar Depression will tell you that the two are absolutely nothing alike.

 * "Depression" (used in a non medico-legal sense) as the word is commonly used in day to day jargon refers to momentary bouts of the blues or melancholy. (and this meaning/understanding is not for any form of medico-legal related fields.)
 * Every human being experiences this from time to time, it is completely normal and after a little while without need of medical intervention you will be back to normal.
 * Unipolar/Bipolar Depression (using as in medico-legal sense) is not anything remotely similar to plain old "Depression."

Clinical/Bipolar Depression is a medical condition as true as diabetes (DM Type-II) or cancer (e.g. breast cancer, testicular cancer etc.).

"Normal" depression is psychological whereas Clinical/Bipolar Depression is both psychological and physiological, it is well documented that drastic alterations occur in the brain as well as other changes occur in the rest of the body.

The importance of these distinctions is paramount (most important), you cannot gain an understanding of these conditions without it.

I will urge people who are reading this and who are fortunate not to have experienced clinical/bipolar depression, to keep this distinction clear in your minds while reading the rest of this book, any related material, and most of all when interacting with those who are diagnosed.

''' Please pay Attention! ''' For the remainder of this document for the sake of simplicity when the word "depression" is used it will refer to the medical condition of Clinical or Bipolar Depression, and the term "normal depression" will refer to the everyday non diagnosed human experience.

Now that the most important distinction and definitions are out of the way lets establish some others.

There are two major types of medical depression
 * 1) Clinical Depression
 * 2) Bipolar Disorder

''Clinical Depression is an outdated term but is still commonly used. Similarly Bipolar Disorder(BD) was formerly referred to as Manic Depression, but Manic Depression is still widely used to refer to it.''

The correct terms to use as accepted by the medical community are: Major Depressive Disorder(MDD) or Unipolar Depression instead of Clinical Depression, and Bipolar disorder instead of Manic Depression.

As I said before there are two major kinds of medical Depression, MDD and Bipolar Disorder. What's the Difference?

In a nut shell Bipolar Disorder is the same as MDD except that it has two alternating phases; Depression and Mania.

The experiences are usually the same symptoms that occur with MDD, except that they alternate with Manic Symptoms.

Without going into too much detail at the moment, for our purposes now just think of Mania as the opposite of Depression or an extremely good mood. ''The phrase extreme highs and lows sums it up quite nicely for our purposes. We'll go into a little bit more detail about mania later but I don't want to leave you thinking the Mania is all fun and games. Even though you do have an elevated mood there are some very negative symptoms that also come along with Manic periods which will be explained latter. ''

While there are some documented differences between MDD and the depressive phase of Bipolar Disorder, for our understanding they are not relevant and will not be addressed in this book. Both MDD and Bipolar depression are more similar than not, have the same basic symptoms and are usually treated in a similar fashion. Unless otherwise specified when the term depression is used it refers to both Major Depressive Disorder and the Depressive phase of Bipolar Disorder.

If you've noticed I said that MDD and BP are the two major kinds of medical depression. There is another milder but still medically relevant form of depression known as dystimia which we'll touch upon briefly later.

Perhaps then some assume that:

Statistics point out that approximately one out of every six people will have a depression (with varying degrees of seriousness) at least once in their lifetime. The magnitude of this number is all the more shocking if one confronts it with the general ignorance about the problem. Even people well-informed about other health issues will often be caught totally by surprise by a depression. I know, I was one of them. Since our early school years we get tons of information about healthy eating, on the perils of smoking and heavy drinking, on avoiding sunburn, etc., etc. But mental health, largely because of the prejudice surrounding any kind of mental illness, is to a large extent ignored. This is more of a tragedy if one realises how far-reaching are the implications for a person's life and productivity, and most importantly, how depression could be avoided altogether if only people knew how to recognize the early symptoms.

As you read through this document, please always bear in mind that whenever the term depression is used it refers specifically to the physical illness more properly described as clinical depression. One also finds the very same word depression used in the context of other mental disorders (such as manic depression ) of which this document does not cover. It is very important to keep this distinction in mind. As an example, consider the people who suffer from bouts of melancholy all through their lives. They often describe their subjective feeling as that of being depressed. However, when one takes a closer look at more objective indicators, they may not show the symptoms of a clinical depression. This document does not apply to them.

One of the enduring myths about clinical depression is that you can cure it simply by convincing a depressed person that life is good and worth living. Likewise, a depressed person will not be magically cured if all of their problems are suddenly solved. In fact, it was my experience (and that of many others) that the factors which contributed to the depression were long past and resolved. However, they had their physical toll in the brain, and that could not be suddenly undone.

Our misuse of language compounds the problem. All too often a perfectly healthy person (brain-wise, of course)will say that they feel depressed when really all they're experiencing is a passing case of the blues. It is far from my intention to dictate how people should use language, but this example illustrates my case. Curiously, one of the tell-tale symptoms of clinical depression is the inability to have strong emotions, including sadness and the blues.

Another important aspect to remember about depression is that it is not an on/off condition. There is a continuum between a perfectly healthy brain and one from a severely depressed person. I estimate that in modern society, those who could be classified as in perfect mental health are probably the minority. Moreover, just like physical fitness goes through ups and downs throughout a lifetime, the mental health of a typical individual will also fluctuate. It is only when the fluctuation dips significantly low for an extended period that the diagnosis of a depression is typically made. Elaborating further on this note, the good news is that a very large number of people who strictly speaking are not depressed and have largely satisfactory lives, could still feel better and happier if they took better care of their brains. The advice herein contained is also for them.

You may wonder why I have bothered to write such a lengthy description of depression if I advise people to seek professional help anyway. In a sense, you are asking for a rationale for this document. Well, I would not have written it if I thought it was irrelevant, dangerous, or simply superfluous- Quite the contrary. I see good reasons that justify it, as follows.

 * The focus of the document is an objective description of clinical depression, explaining the physical illness which progressively takes its toll on the brain. If more people were aware of this fact, they would not be as complacent when the first symptoms appear. Moreover, they would feel less stigmatised and reluctant about seeking professional help.

 * By being better informed, people would realise the importance of seeking competent help. Many General Practitioners and even Psychologists are not properly informed about depression, and they can even inadvertently give their patients plenty of bad advice. Worst of all, the situation can worsen dramatically before the patient even realises what is wrong with the advice they are given. This happens frequently, believe it or not. The only solution is for people to be better informed and able to spot whether or not their GP is competent enough to treat them.

 * The enormous cost of health care in affluent societies often translates into health insurers pressuring for the cheaper solution of relying solely on antidepressants. In countries where the GP stands as the gate-keeper for specialised treatment, people may find it difficult to convince their GP to send them to a specialist. The result is treatment based largely on medication, with little or no coaching.

 * Lifestyle plays a large role in the development of depression. Again, by better understanding the problem from an objective perspective, people will more easily assimilate the need to take good care of their sleep and to avoid overloading their brains.

The remainder of this instalment is structured as follows. I will begin by explaining what exactly is a depression and how the problem develops in the first place. Special attention will be given to a description of the most typical symptoms which accompany each stage of the illness. The next step is more personal: it describes the lifestyle changes I had to make to help my brain recover instead of sinking deeper into the illness.

title: Demystifying Depression/Introduction


text:
Demystifying Depression/What Is Depression

What is Depression?
Depression is a very real medical condition that involves both psychological and biological factors. It is not simply "in your head". Numerous studies have shown significant changes occur to the anatomy of the brain during the course of depression. Depression is a whole body illness, not only affecting the brain. Those with depression experience a wide variety of physical and mental symptoms. Strong emphasis should be placed on the fact that depressed mood is only one symptom of many involved in an illness that encompasses many.

According to the World Health Organization (W.H.O.) Depression is a common mental disorder that presents with depressed mood, loss of interest or pleasure, feelings of guilt or low self-worth, disturbed sleep or appetite, low energy, and poor concentration.


text:
Demystifying Depression/The Stress System

The Stress System: Adrenaline and Cortisol

The stress system relies on two key hormones: adrenaline and cortisol. In short, adrenaline works in the short term, while cortisol has large momentum and works in the long term. (Adrenaline is also known as epinephrine in North America. To be exact, the terms noradrenaline and norepinephrine are used to refer specifically to the neurotransmitter as opposed to the hormone, since they are different molecules. Moreover, there are many other neurotransmitters involved: check reference for details. The purists will excuse my exclusive use of the word adrenaline throughout the text).

It is important to realise that the stress system can also be activated if your brain perceives danger or any kind of threat. In the first stage, this triggers the release of adrenaline into the bloodstream to prepare the body for action. As a result, your heart beats faster, you begin to sweat, your breath becomes shallower, and your senses become more acute. This is the so-called fight or flight response to the stressor event, and was quite adequate during most of our evolution, when these events were quite specific and usually short-term: escaping from a lion, chasing away a rival gang, or facing up to the impudent adolescent trying to woo your mate. Problems with chronic stress arise because in a modern society we cannot escape easily from the stressor, be it an overbearing boss, crowded cities, or traffic jams. Furthermore, no matter how hard we try to delude ourselves with the pretence of civilisation, at heart we are still primates, and consequently, factors such as social status also play an important role as sources of stress. Moreover, primates have evolved the capacity to stress up the body in anticipation of a possible danger. Again, this was an advantageous adaptation in the context where it evolved, but nothing but trouble for the modern human.

The effect of the stress hormones on the brain is curious and not what you might expect. The initial surge of adrenaline can make you feel good.

Just as your levels of adrenaline start coming down, so rises the amount of cortisol flowing through your veins. Moreover, cortisol has a much larger momentum than adrenaline, which means that even though it builds up slowly, it also takes a long time to go back to normal. And should you constantly be engaging in activities which require adrenaline, so will your levels of cortisol slowly increase. In a sense, you can think of cortisol as a measure of the weighted average of your recent levels of adrenaline. I have tried to capture this feature in Figure 2.

Together with the rise of cortisol and the decrease of adrenaline, come the nasty side-effects of the stress hormones. It is at this moment that you feel bad, anxious, and having lots of negative thoughts. And this is perhaps one of the critical features of stress which flies against common sense: you only feel its bad aspects when your body is stressing down and progressing towards a more relaxed state. When you are building up on adrenaline, in effect stressing up, you might even be feeling good! This explains what is popularly known as the adrenaline rush and the consequent adrenaline crash.

Having too much cortisol flowing through your veins has another nasty side-effect: the recovery time from any adrenaline surge increases. In a sense, the relation between adrenaline and cortisol goes both ways: the adrenaline curve influences the cortisol curve, and vice-versa. Figure 3 tries to capture this reaction effect by showing the adrenaline response curve for three individuals subjected to the same physical exercise. Notice how the more serious the depression (which translates into higher levels of cortisol, as you will soon understand), the longer it takes for the body to go back to normal.

On the speculation front, recent findings may have implicated neuron death as the physical underpinning of depression. Furthermore, it seems that the opposite process, termed neurogenesis, is crucial for the recovery, and happens naturally in healthy individuals [3,6]. Furthermore, evidence indicates that sleep is fundamental for neurogenesis to take place.


text:
Demystifying Depression/The Buildup to a Depression

At this stage you are in possession of all the ingredients necessary to understand how depression develops. The negative effect of the stress hormones on the maximum normal capacity is the key to comprehend the buildup process that makes a depression feed on itself, like a positive feedback mechanism.

Let us go back to Figure 4. Imagine that you would chronically go over your limits, thus forcing your body to constantly rely on the stress hormones to compensate for the lack of serotonin. On the long term, your maximum capacity would therefore be reduced, making it much more likely that you would have to resort to the stress system to compensate. And thus the feedback begins: your maximum capacity is diminished, forcing you to use the stress system all the time; and because of all the stress hormones flowing through your veins, your brain has no chance of recovering, and your maximum capacity diminishes even further.

This may sound very mechanical, but I would say that it is the key element that leads to the development of a full-blown clinical depression. Alas, it is also something that most doctors fail to realise. And if you are still clinging to "psychological" notions about the illness, it is time you put them into perspective. Psychology plays a role in the factors that lead to the initial dip of your work capacity, but after a certain stage the problem just feeds on itself, and it is crucial to understand that to avoid falling prey of this downward spiral.

Even though the graphs might give the impression that this is a phenomenon that happens very quickly, in reality the process typically takes many years to develop. Moreover, the progressive increase of the levels of stress hormones in your body provide a very good advance warning, if only you know how to read them. I will now provide a basic description of what to expect (and what to do!) at each stage of the process. Beware that different people have different symptoms, so your mileage may vary.

Early stages
In the very early stages, a depression will not feel like a depression at all. The small amounts of stress hormones could in theory be measured—your blood pressure would be slightly higher than otherwise—but in practise it would be difficult "to extract the signal from the noise". Subjectively, you might feel a bit down and tired, especially during those periods when you are crashing down from the adrenaline, but most people would still not say that they feel depressed. Also, you would start sleeping a bit less than usual, and not feeling quite as fresh when you wake up.

The problem is not very serious yet, and I think that most people could recover on their own if they were to simply take a long holiday and to make sure that they sleep well. There is some evidence that if done properly moderate amounts of aerobic exercise might help at this stage. However, be sure to read ../The Role of Sports/ section before you decide to embark on any exercise routine. In fact, I would rather advise people not to begin exercising than to risk having them over do it and making their condition worse. I know this flies against some commonly held beliefs, but sports alone can worsen a depression. If you do not believe now, read carefully both installments of this document and you might understand what I mean.

Elevated stress hormones
As the amount of stress hormones increases, you will start feeling some of their nasty side-effects. This is largely person-dependent, but most people start having problems with their digestive system, headaches, and having more frequent nightmares. Since stress depresses the immune system, people also tend to fall sick with infections more often. Only a minority of people suffer from sleep paralysis, but it is also a good indicator of elevated stress hormones. An objective measure such as blood pressure should be controlled: it will definitely be higher than normal, and a good doctor would not fail to recognise it. At this stage you are very clearly sleeping less than normal, waking up early in the morning, feeling tired and "lazy" about getting up. Subjectively, you should notice that you do not feel things quite as intensively as you used to: you feel empty, morose, and definitely "depressed" most of the time. Other subjective indicators include loss of appetite and sex-drive, feelings of guilt, lowered self-esteem, and detachment from hobbies or friends.

At this stage you should not be complacent about the problem. The best thing you can do is to go see your doctor. Take also into consideration that you have been putting too much pressure on your brain. Really do give it a rest: take a long holiday, make sure you sleep well, and be careful not to get any extra responsibilities. Antidepressants are very effective at this stage, especially if combined with minor lifestyle changes. (And yet another reason why you should see your doctor!)

Problem aggravates
As the buildup towards a depression continues, you get to the point where it is impossible not to notice that there is something definitely wrong. At this point, most people start having serious problems with anxiety, stress, panic attacks, hyperventilation, bouts of psychosis, etc. Your sleep will definitely be a mess, your blood pressure will be high, and your ability to focus at work seriously compromised.

One should definitely seek professional help at this stage. In particular, do not make the assumption that your GP will be qualified to treat you. They may, or they may not. Unfortunately, many doctors still do not quite understand what is going on. My experience in this area was quite bad: I spent more than one year jumping from doctor to doctor, with the problem constantly aggravating, and getting all kinds of bad advice. In short, you need to stop. Your maximum capacity will probably be so low that you cannot even work full time. Also, specifically ask your doctor for antidepressants. In the country where I live, the Netherlands, this is bit of a taboo subject, so depending on where you live, you might need to convince your doctor not to be stingy and stubborn. Should they suggest that you start exercising, just ignore that advice. It is a very good indicator that they do not have a clue of what is going on. Also, you will need to make changes to your lifestyle. The ../Recovery Guide/ section describes one author's personal experience in that regard.

Last stages
In the last stages, the maximum capacity is practically nil, and the level of stress hormones so high that people cease to be able to function. The stage of a clinical depression is very difficult to describe in words, but I will do my best. The anxiety transforms itself into a "fire" which constantly burns inside your head; you will feel desperate, much more than you ever felt in your life, as if you could never be happy again; and you will definitely be suicidal, to the point of actually planning suicide or even attempting it (with success in many cases, tragically). During this stage, people can barely sleep, if at all.

To an outsider, the fact that a clinically depressed person is pretty much confined to bed is often misinterpreted. People often think that a clinical depression is a simply a state of apathy. Quite on the contrary: remember that the blood pressure and heart rate of a depressed person are extremely high. Rather than apathy, depression is an overwhelming fire which will not subside and burns you from the inside.

Unfortunately, it is only at this stage that many people finally concede that they need professional help to treat them. Needless to say, you will need to make drastic changes to your lifestyle if you want to recover. You should also be very patient: it will take a long time before things go back to normal. Most important of all, a clinical psychiatrist is the proper specialist to accompany you during this period.


text:
Demystifying Depression/Recovery Guide

Recovery Guide
There are plenty of people with depression who are not being properly treated. Antidepressants revolutionized medicine's approach to the treatment of depression, and even though they are generally effective and an indispensable tool, sole reliance on drugs neglects valuable lifestyle advice. This is important consideration for those with all levels of depression.

The first step tried in recovering from depression should be telling someone and then getting help from a doctor if possible.

In order to recover from a depression, one must first understand the problem.

The following three sections cover the different aspects of the lifestyle changes. The first category deals with general advice which one should always have present. I The next section deals with the daily routine. Even though more flexible in nature, I quickly realized that there were good reasons behind my counselor's insistence that I followed its guidelines. At last, the third section focuses on tips for good sleep. These are by no means specific to a clinical depression.

title: Demystifying Depression/Recovery Guide


text:
Demystifying Depression/General Lifestyle Advice

General Lifestyle Advice
These are just the general tips that might help with depression. It might take a while to get used to them, but in time they will become second nature. Moreover, remember that depression is not an on/off condition: this same advice is also useful for healthy people who wish to remain that way. Obviously, a healthy person does not need to follow them very strictly, but they remain nevertheless good lifestyle advice.

 * Try to avoid stress

Stress may exasperate depression

 * Exercise

 * Get Sunshine

 * Do things you enjoy

 * Practice relaxation exercises

Yes, I am referring to stuff like meditation and yoga. They actually work, despite all the silly new-age nonsense that surrounds them. If you cannot stand the airy-fairy aspects, try to find a good expert who does not preach them.

Personally, I found that one of the most relaxing things you can do is to lie in the sunshine. This might not be an option if it is winter and/or you happen to live in a cold country, but if you can, do it as much as is safely possible. (But take into account the usual advice concerning the dangers of catching too much sun, obviously! Like in all things, moderation is the key).

Make a conscious effort to do things with pleasure

This could take a fair amount of brainwashing, but the idea is that before each activity, no matter how small, you think I love doing this or I order myself to feel good, right now. For best results, say it loudly. Also, only do things when you really feel pleasure in doing them, and do them only for as long as that pleasure remains. Should you lose interest or feel tired, then stop.

Take appropriate medication

If your gut reaction is that antidepressants are evil, consider informing yourself properly. The truth is that modern drugs are quite effective and generally safe (I am referring in particular to SSRIs and more recent classes ). They do have side-effects, but these are usually mild and quite bearable compared with the illness itself. For best results, have a clinical psychiatrist prescribe them to you: they are generally well informed of the different side-effects and can choose the drug best suited to your case. Also, remember that antidepressants usually require around three weeks before they have an effect. Three weeks are an eternity for someone with a depression, but do not stop taking them just because you do not see an immediate result.


text:
Demystifying Depression/Daily Routine

Daily Routine
I will now make a brief description of the typical daily routine. This advice assumes that the person is in a serious condition, but there are still a few good pointers to extract even for mildly depressed individuals. Also, as the condition improves, one does not need to be as rigorous as in the early stages.

 * Take your time to do the morning activities

You surely do not want to rev up your body immediately after waking up! Take your time to get up, to shower, to get dressed, and to breakfast. If it takes you less than one hour and a half to perform these activities, then you are doing them too quickly.

 * Take a walk in the morning

The idea is to have a qualitative walk. Pay attention to the colours around you, to the smells, the sounds, the shapes, the people, etc. This will help to diffuse your thoughts, and to avoid the obsessive thinking that accompanies depression. Also, since you must limit physical activity, walking every morning is important for your body to burn excess sugar. Walk for about half an hour, and do not forget: lie down for another half an hour afterwards! (Remember Figure 3: your body will take longer than usual to get back to normal).

Like gardening, painting, or bird-watching.
 * Find an activity that gives you pleasure

 * Eat properly and avoid heavy meals

Digestion is also quite demanding on your body, and therefore it is better to have more meals rather than bigger meals. Also, a depression is really a bad time to be thinking of diets. Eat well and make sure you get all your nutrients.

Some people also swear by the importance of drinking water regularly during the day. The rationale is that dehydration is a stress event, thus triggering the physiological reaction we aim to avoid.

 * Have a siesta

Even if you cannot sleep, it is important that you lie down for a while until your body is (relatively) rested. We all have a natural dip after lunch, and it is a pity that some modern societies have lost the siesta habit.

title: Demystifying Depression/Daily Routine


text:
Demystifying Depression/Tips for Good Sleep

Tips for Good Sleep
To conclude, I will present just a few tips on how to get a good night's sleep. These are especially important during a depression, but again, they also apply to anyone.

 * No activities before going to sleep

You must avoid at all cost any adrenaline coming into your system before sleep time. Be especially careful of anything exciting or stressful. Yes, this includes most of television and even reading! Avoid also any physical exercise less than an hour before going to sleep. Always have in mind that a person with a depression will need longer than normal for the body to recover from any physical effort. Even healthy individuals should avoid doing sports at least a couple of hours before going to bed.

 * Follow a steady sleep routine

Try going to bed always at the same time everyday. We all know how working in shifts and jet-lag affect sleep: do not emulate them by going to bed at random times each day!

 * Give your body time to crash down

You cannot fall asleep while there is too much adrenaline running through your veins. It can take a while (even hours) before you crash down, and often people lie awake in bed waiting for sleep to come. The problem is that after a while it is very easy to start obsessing about not sleeping, which is a sure way of keeping yourself awake.

The idea is to only get ready for sleep once you have crashed down and feel tired. Before you actually get into bed, just lie there for a while (even with your clothes on), until you feel relaxed and tired.

 * Go to bed early

There are several reasons why this is a good practise: foremost to be able to wake naturally rather than with an alarm clock; but also to avoid being out of sync with the solar cycle, and to give your body time to crash down.

 * Make your bedroom your sanctuary

Do not have an office in the same room as where you sleep. Dedicate one room simply for sleeping, and make it as uncluttered as possible.

 * Sleeping Medication

Sleep is the most important part of your day. If all other methods and tips on how to get a good night's sleep fail; talk to your doctor about taking a low dose sleeping medication.


text:
Demystifying Depression/The Recovery Process

The Recovery Process
Depending on your age, your general health status, how serious the depression was, and how well the recovery progresses, it typically takes between two months and two years before you can be fully recovered. Do not despair, however, because this certainly does not mean that during all this period you will feel as bad as in the beginning. The first few months are the hardest, but after that things will slowly improve, and little by little you will get your happiness and normality back. Moreover, remember that you only feel the nasty aspects of a depression when you go over your limits: you just have to be patient and to realise that your limits will indeed be very short during an extended period.

As the recovery progresses, you will feel not only that you can perform more concentration intensive activities and during longer periods, but also that your subjective mood improves. At some point you will be able to start working again, only for a couple of hours each day in the beginning, but increasingly more until you can work full time again. Finally, your mood should start approaching normality towards the later stages of the recovery: you should regain the feelings of fullness, vibrancy, and what is sometimes called the elan vital.


text:
Demystifying Depression/Conclusion

Conclusion
The moral of the story is fairly straightforward: depression is a physical illness which should be taken seriously and be treated as soon as the first symptoms arise. Like most other ailments, it feeds on ignorance and complacency, which is all the more tragic if one considers that we have the medical knowledge and the means to make it a thing of the past. Humanity has been tormented too much already.

title: Demystifying Depression/Conclusion