A technical definition of a function is: a relation from a set of inputs to a set of possible outputs where each input is related to exactly one output.

This means that if the object $x$ is in the set of inputs (called the domain) then a function $f$ will map the object $x$ to exactly one object $f(x)$ in the set of possible outputs (called the codomain).

The notion of a function is easily understood using the metaphor of a function machine that takes in an object for its input and, based on that input, spits out another object as its output.

A function is more formally defined given a set of inputs $X$ (domain) and a set of possible outputs $Y$ (codomain) as a set of ordered pairs $(x,y)$ where $x \in X$ (confused?) and $y \in Y$, subject to the restriction that there can be only one ordered pair with the same value of $x$. We can write the statement that $f$ is a function from $X$ to $Y$ using the function notation $f: X \to Y$.

For more information about functions, check out the function machine or the function examples.