What is a function?



A defense software consulting company has monitored the costs of different software development projects and has compiled the following table.

Project Name Duration (in months) cost (in $1,000)
P00115315
P00210215
P003501,015
P00425515
P00510215
P00625515
P00715315


Did you notice that there is a simple relationship between project duration and cost? If we look at the table, we find that
Cost = 15 + 20 * Duration

This is a much more compact and useful description of the data than the table is. We can use this to describe any project in the table and also to estimate the cost of a new project.

In general,

A compact description of the data, that gives the values of some of the fields in terms of the others, is called a function.

A variable y is a function of x if a relation between x and y produces exactly one value of y for each value of x. In other words, a function "maps" one type of value to another. In the above example, project durations are mapped to costs.

Usually a letter is assigned to the function name. We can say that C(d) is the cost of a software project of duration d, and the formula is

C(d) = 15 + 20 * d

The set of all possible values that are allowed as inputs to the function is called the domain of the function and the set of all the values that are allowed as outputs is called the range of the function. In the project cost table, durations are the domain; they are measured in months between 0 and 50. Costs are the range; they are measured in multiples of $1,000 and vary between $215 and $1,015. For more details on the domain and range of the functions, please refer to Domains and Ranges station.