Functions in this visualization
A function from a set to a set , written , pairs every element of with exactly one element of , written . It is also called a map or mapping. is the domain, the set of inputs; is the codomain, where the outputs may come from; the outputs actually reached form the range, or image. Here you draw the pairing as arrows from to and see the same pairs as points on a grid; the readout says whether they make a function and, if not, which input breaks the condition.
What the condition checks
The condition is about the inputs only. Each input needs an output, and only one: an input with no arrow, or with two or more, means the pairs are not a function from to . The outputs have no such condition. Several inputs may share an output, as and share under , and elements of may receive no arrow at all; a constant function sends every input to the same output.
Nor does a function need a formula: giving each input any one output defines a function, whether or not some formula describes it. And an equation does not guarantee one. On these sets pairs with both and , and gives , and nothing in .
The inputs come first
Whether a set of pairs is a function depends on . Start with the function in the first highlight and remove its arrow . What is left is no longer a function from to , because is in and has no output; yet the same arrows are a function on the smaller set . Shrinking the set of inputs only settles the inputs you leave out, though: on , is still not a function, since still has two outputs and , and still have none. When a function is given only by a formula, its domain is usually taken to be every for which the formula makes sense. Some areas, such as computability theory, also speak of partial functions, which may leave inputs without an output; a function from to , as on this page, leaves none.
The vertical line test
On the grid, the vertical line through an input meets one point for each output of . So the pairs are a function from to exactly when, for each in , the vertical line through meets exactly one point; lines through numbers outside have nothing to check. The test is the definition read off the graph, since the arrows and the points are the same pairs.
Controls
- Drag from a number in to a number in to draw an arrow, or to remove one already there; or click one end, then the other.
- Click a grid cell to place or remove a point. With the keyboard, focus the picture, move with the arrow keys and press Space.