# 4.4.A Formalising the notion of functions

In mathematics, of course, we need to work with functional relationships in the abstract. To do this, we introduce the idea of function. You should think of a function as a mathematical object that expresses a functional relationship between two sets. The notation f → expresses the fact that is a function from the set to the set B. That is, fis a name for a mathematical object that expresses a functional relationship from the set A to the set B. The notation → is read as “ is a function from to B” or more simply as “ maps to B”.

Mathematical functions are different to functions in a programming language in Java. We’ll come back to this in the next section.

If → and if ∈ A, the fact that is a functional relationship from to means that associates some element of to a. That element is denoted (a). That is, for each ∈ A(a) ∈ and (a) is the single, definite answer to the question “What element of is associated to by the function ?” The fact that is a function from to B means that this question has a single, well-defined answer. Given ∈ A(a) is called the value of the function at a

For example, if is the set of items for sale in a given store and is the set of possible prices, then there is function → which is defined by the fact that for each ∈ Ic(x) is the price of the item x. Similarly, if is the set of people, then there is a function m→ such that for each person pm(p)is the mother of p. And if $$\mathbb{N}$$ is the set of natural numbers, then the formula

$$s(n)=n^{2}$$ specifies a function s: $$\mathbb{N} \rightarrow \mathbb{N}$$.

It is in the form of formulas such as $$s(n)=n^{2}$$ or $$f(x)=x^{3}-3 x+7$$ that most people first encounter functions. But you should note that a formula by itself is not a function, although it might well specify a function between two given sets of numbers. Functions are much more general than formulas, and they apply to all kinds of sets, not just to sets of numbers.