Foundations & functions

domain and range

Every function has a list of inputs it is allowed to accept and a collection of outputs it actually produces. The domain is the set of allowed inputs — what you are permitted to feed in. The range is the set of outputs that come back out. Think of a juicer: the domain is the fruit it can handle, and the range is the juices that can result.

Domains matter because some operations simply have no answer for certain inputs, so those inputs have to be excluded. You cannot divide by zero, so for f(x) = 1/x the value x = 0 is thrown out of the domain. In the real numbers you cannot take the square root of a negative, so for g(x) = sqrt(x) the domain is x >= 0. The range is then whatever the function can reach: for g(x) = sqrt(x) the range is the outputs y >= 0.

It helps to keep two ideas apart: the codomain is the space the outputs are declared to live in (often all real numbers), while the range is the part of that space the function genuinely hits. The range can be smaller than the codomain — f(x) = x^2 has codomain all real numbers but range only y >= 0, since a square is never negative.

g(x) = sqrt(x): domain x >= 0, range y >= 0

Negative inputs are excluded, and outputs never dip below zero.

Finding the domain is mostly a matter of forbidding trouble: no dividing by zero, no even roots of negatives, no logs of zero or negative numbers.

Also called
domainrange定义域值域