✖

Functions of several arguments

The simplest functions usually have just one parameter. They are easy to work with and easy to analyse. In real life, though, we sometimes need more complicated functions with several parameters.

What a function of several parameters looks like

So far we have worked with functions that have one parameter. However, a function can easily have two parameters, or even more. You work with such a function in the same way as with a function of one parameter; in the table analogy we simply have more columns for the inputs, but still one column for the output. Such a table might look like this:

Input aInput bResult11212315635841216

We write such a function much like a function with one parameter, only we put two parameters in the brackets: f(a,b). A call would look like f(1, 2). To evaluate it, we would find the row where Input a = 1 and Input b = 2. On that row the Result column has the value 3, so f(1, 2) = 3.

Notice that some values appear several times in the input a column. We have already said that a function must always return the same result for the same input. Does that still hold when the same values appear in one input column? It does, because the other column tells them apart. So it is fine for the number 1 to appear several times in the first column, because each time it has a different value in the second column. We call the function with two arguments, so for every identical pair of arguments the function must return the same result. A bad table would look like this:

Input aInput bResult1121231563483413

The last two rows have the same input values, so this table is not a valid definition of a function. This function would not know what to return if we called it with the arguments f(3, 4).

Examples of functions of several parameters

In maths, a power is an example of a function of two parameters. The power function takes the base as one argument and the index as the other. To be clear, the notation x2 is really a call of a function of two parameters. If we wanted to define raising to a power by hand as a function, we could do it like this:

power(a,b)=ab

The parameter a is the base and the parameter b is the index. We could therefore also write x2 as power(x, 2). In the body of the function, the variable x would be substituted for the parameter a and the index 2 would be substituted for the parameter b. And we are back to the expression x2.

Other examples are the familiar operations of addition and multiplication. Addition and multiplication are nothing other than functions of two parameters:

add(a,b)=a+bmultiply(a,b)=a⋅b

Chapters: What is a function, Functions of several arguments, Composition of functions, The graph of a function