Visualgebra

Input and output

A rule that takes one number and always gives back exactly one — the idea behind every function.

The last lesson checked whether a point satisfied a fixed equation, one at a time, on a coordinate plane. This lesson reframes that same idea as a machine: feed a rule a number, and it hands back exactly one number in return — read directly off the rule’s own line below.

A labelled x and y axis, with the line for "double it, then subtract 1" drawn across it. P sits on the x-axis: the input. A live reading substitutes P into the rule, showing each step, and names Q, the point where a vertical line through P meets the rule's own line -- the input and its output together. This needs JavaScript switched on.

Drag P along the x-axis. Q always lands exactly on the rule's line.

A rule is a sequence of steps, followed in order. “Double it, then subtract 1” means multiply first and subtract second — reverse the order and the same starting number gives a different answer. That one requirement, one number in and exactly one number out, is what separates a rule worth calling a function from a vague instruction: it can never hand back two different answers for the same starting number.

The number fed into a rule is its input; the number the rule hands back is its output. Working an input through a rule’s steps to find its output is substituting.

Once every input has exactly one output, the pair — input and output together — is a single point, Q, sitting on the rule’s own line. This lesson only ever plots one such point at a time; the next lesson plots all of them at once, which is what turns a rule into the picture called its graph.

A rule is “triple it, then add 2.” What is the output for an input of 4?

4×3=124 \times 3 = 12, then 12+2=1412 + 2 = 14.

The same rule, “triple it, then add 2,” for an input of 3-3.

3×3=9-3 \times 3 = -9, then 9+2=7-9 + 2 = -7.

A rule is “add 2, then triple it” — the same two operations as above, in the opposite order. For an input of 4, is the output still 14?

No: 4+2=64 + 2 = 6, then 6×3=186 \times 3 = 18. Order is part of the rule, not a detail that can be rearranged.

Do the exercise

This lesson counts as done once you get its exercise right. Nothing to tick off by hand.