Function: In logic and mathematics: Statement to the effect that two sets (or collections) A and B are correlated in some way such that every element of A is correlated with precisely one element of B.
The first one to isolate and name this important concept explicitly seems to have been the mathematicians Euler and Lagrange, who started using it it in analysis, on the pattern "if f is a function f(x)=x^{2}, then the differential  the derived function  of f is written as f'(x)=2x".
It is also quite useful outside logical and mathematical contexts, and may be restated then in terms of collections A and B between which there is a function as specified as above.
Returning to the moment to sets, there are many useful concepts involving functions.
To start with, it is important to notice that the simplest functions have one argument, as in f(x)=2x  which incidentally equals 4 for the value 2 i.e. f(2)=2.2=4  but also may have more arguments. In case a function has n arguments, it is called an nary function.
Thus sum and product are conventiently construed as functions of two variables, a.k.a. as binary functions, say sum(x_{1},x_{2})=x_{1}+x_{2} and product(x_{1},x_{2}) =x_{1}*x_{2}. This idea may be extended to arbitrarily many arguments, as long as their results (output) for given values (inputs) are unique, as required by the definition of 'function'.
As instantiated above with differentials, functions, like x^{2}, may be subtly related to other functions, like 2x.
If f is a function from A to B  briefly: f : A > B, also written as "f maps A to B"  then there is the following useful terminology:
A is the domain of f
B is the range of f
f is onto iff every element of B is related by f to some element in A
f is injective iff f is not onto
f is surjective iff f is onto
f is partial iff not every element of A is related to some element in B
f^{1} is the inverse of f iff f^{1} = {(y,x) : (x,y) e f}
Note that f^{1} is not necessarily a function. If it is, i.e. if for every y in f^{1} there is just one x:
f is a 11 function IFF f^{1} is a function and f is a function.
This property can be used  as Hume already saw  to say something useful about the number of elements of a set: Two sets have the same number iff there is some 11 function between them. One does not need to know the number of men or of their noses to know these are the same iff every man has one nose and every nose belongs to one man.
The notion of a partial function is useful for many cases, of which a wellknown one gives one reason for the notion of a partial function: Division in arithmetic is functional for all numbers, except if the divisor is 0, for then division is undefined. Hence division can be regarded as a partial function of pairs (x,y) of numbers to numbers z, where y=0 is excepted.
Furthermore, if f : A > B and g : B > C then there is a h : A > C such that h(x)=f(g(x)). Here f and g may be of arbitrary arity. This is called composition of functions and one often writes "fog" for "f(g(x))". A simple algebraic example is square(sum(x_{1},x_{2})).
One useful way of trying to analyse or understand something using the concept of functions is to try to regard it as the functional output h of some composite functions f and g one tries to find. Thus, one way of analysing the function h with given pairs {(0,0), (1,4), (2,16), (3,36), ..} is as h(x) = square(sum(x_{1},x_{1})) = square(2x).
Also, it should be clear that functions are a special kind of relations, namely precisely those nary relations of which the nth term has a unique value for any values of its other terms.
