In math the word function is exemplified generically as
We say y is a function of x. Sometimes the following, slightly less generic, version might be expressed as the linear function
where a
and b
are constants, and
x
is the variable expression.
A more concrete example might be, again a linear function:
If we choose and insert a value for x, do the calculation
on the right hand side on the equals sign, =
we get a value that is then assigned to y
.
This is useful because it describes how to calculate the
value of y
for any chosen x
.
This is useful if we want to draw the line described by the function, let us say
Giving us a coordinate set of (-5, 0)
ie the
chosen x
, and the calculated y
.
Choose another x
Giving us another coordinate set (3, 4)
,
allowing us to draw the line in a coordinate system.
In mathematics we use functions to specify calculations. A function is the right hand side of a mathematical expression such as in the above examples. As such it is always a one liner. Now we shall turn to computing where a function is used to execute a specified activity. Not necessarily a one liner. Sometimes it is a calculation, but at other times it might be a series of statements necessary to achieve a required purpose.