How does a set of functions form a monoid? While I now understand what monoids are I am still not sure how a set of functions, under composition defines a monoid.
The main difficulty I am having is understanding how you can define composition. I mean for integers under $+$ it's easy. Define our binary operator to be plus, so:
$x \cdot y = x + y$
and we know what $x+y$ means...
But for functions:
$f \cdot g = f(g)$ <---????
Clearly we can't write $f(g)$ because it then makes no sense to write: $f(g)(x)$
I'm probably completely wrong about something...
References:


*

*http://reperiendi.wordpress.com/2007/09/12/monoids/
 A: Given two functions $f, g : X \rightarrow X$, their composition $f \circ g$ is a new function $X \rightarrow X$. When $f \circ g$ is given an argument $x \in X$, it first applies $g$ to produce an element $g(x)$, and then applies $f$ to that. The result is $f(g(x))$, and this element is defined to be the value of $f \circ g$ in $x$.
Summing up, we get what Srivatsan wrote in a comment:
$$
(f \circ g)(x) = f(g(x)).
$$
Since we defined an operation that takes two functions $f$ and $g$ and produces a new function $f \circ g$, it makes sense to check if the operation makes the set $X^X$ of functions $X \rightarrow X$ into a monoid.
To do so, we need to prove that composition is associative, i.e.:
$$
(f \circ g) \circ h = f \circ (g \circ h)
$$
for any choice of $f, g, h$, and also that there exists a special function $i : X \rightarrow X$, such that, for all $f$:
$$
f \circ i = i \circ f = f.
$$
All of this is extremely easy to verify, just keep in mind that to check if two functions are equal is it sufficient to check that they have the same value on every possible argument.
A: if $f:X\to Y, g:Y\to Z$ are two functions, then the composition $g\circ f:X\to Z$ is defined by first doing $f$, then doing $g$, ie $(g\circ f)(x)=g(f(x))$.  for example, if $f:\mathbb{R}\to\mathbb{R}$ is given by $f(x)=x+1$ and $g:\mathbb{R}\to\mathbb{R}$ is given by $g(x)=x^2$ then $(g\circ f)(x)=(x+1)^2$ (and $(f\circ g)(x)=x^2+1$ so that that composition is not commutative when defined).  one has the identity function from a set to itself, and composition is associative when defined.  so the set of all functions from a set to itself is a monoid.
