Skip to content

Functions: One Output for Every Input

Textbook

A function $f:A\to B$ assigns exactly one element of the codomain $B$ to every element of its domain $A$. The notation $f(x)$ is its value at input $x\in A$. Different inputs may share an output, but one input cannot have two different outputs.

The image $f(A):=\{f(x)\mid x\in A\}$ is the set of values actually produced. For $f:\mathbb R\to\mathbb R$ with $f(x)=x^2$, the image is $[0,+\infty)$, smaller than the codomain.

In $f(x;\theta)$, $x$ is the varying input while parameter $\theta$ fixes a particular function. With $\theta=2$, the rule $f(x;\theta)=\theta x$ becomes $2x$. During fitting, the parameter itself becomes unknown. A letter’s role, Latin or Greek, comes from the problem rather than its alphabet.

A function specification includes the domain, codomain, and assignment rule. The formula $1/x$ does not define a real function on all of $\mathbb R$, because zero receives no real output. Restricting the domain to nonzero numbers fixes this issue. Two expressions with differently named arguments can describe the same function: matching assignments on the same domain matter, not the variable’s name.

Definitions and further reading: Mathematics for Computer Science.

In plain language

A function resembles a machine that assigns one definite output to each allowed input. Different buttons may dispense the same tea, but one button cannot randomly choose among different drinks. The domain specifies allowed buttons, the codomain specifies allowed answers, and the image consists of answers actually attained. A “drinks” label guarantees nothing beyond tea; the function describes the assignment rather than the machine’s speed.

Example

The example evaluates the square function at three illustrative inputs. Two different inputs produce 4, and zero produces 0. No negative output occurs, although the codomain permits negative numbers.

Functions: One Output for Every Input

Input 2

Squaring the positive input gives 4.

Step 1 of 3: Input 2

Read all steps
  1. Input 2

    Squaring the positive input gives 4.

    State
    2current4current
  2. Input −2

    Another input gives the same output, which is allowed.

    State
    −2current4current
  3. Input 0

    Zero is attained, but negative values are not.

    State
    0current0currentimage: [0, ∞)current

The three calculations show that different inputs may share an output. Describing the image of the entire real line requires two further checks: every real square is nonnegative, and every $y\ge0$ is attained at input $\sqrt y$. The image therefore equals the whole nonnegative ray rather than merely containing the displayed 0 and 4. Three demonstration rows alone cannot recover the complete image.

Related concepts: Real intervals.

The original text of this free article is published under CC BY-NC-ND 4.0.

Previous / next

Previous
Real Intervals: Are the Endpoints Included?
Next
Function Composition: Feeding One Output Into Another
  • Natural Numbers: Counting Discrete Objects

    Which values count discrete objects, and why the zero convention must be stated.

    Read article
    Math
  • Integers: Counting on Both Sides of Zero

    Positive and negative integers, zero, and the limits of integer division.

    Read article
    Math
  • Rational Numbers: Ratios of Integers

    Numbers as ratios of integers: equivalent fractions and the nonzero denominator requirement.

    Read article
    Math