The term “function” only entered mathematics around the 17th century with Leibniz concurrent with the development of calculus and analytical geometry (such as the study of curves in the plane). Before this notions of dependent and independent variables that we are used to when studying
were not so well formalised. Arguably there was some work in this direction around the 12th-14th centuries by mathematicians such as Sharaf al-Din al-Tusi (who developed systematic method for numerical approximation of the roots of cubic polynomials) and Nicole Oresme (who first proved that the harmonic series diverges). Around the 19th century developments in mathematics required more general notions of functions and mathematicians, such as Dirichlet, Dedekind and Cantor, pushed away from the notion of a function as a formula and towards more general definitions such as the one above.
Once we have this more general idea of a function, we need ways to represent it. A very natural way (once Descartes introduced it — though it was also developed concurrently by Fermat and much earlier by Oresme) is to plot the function as a curve in the plane. Each point on the curve represents a pair of coordinates
so that
With this more general idea of a function we might try drawing something like we did above for the days-of-the-week example. That is, we might draw two sets of elements and edges between them to indicate that the function applied to that element in the first set gives the corresponding element in the second.
We could also just explicitly write out the mapping. So, for example, if the sets in the first of these functions are
then the function can be written as
Both these approaches are reasonably practical when the domain and co-domain of the function are small, but is really not going to work as soon as they get a little bigger.