Free degree-level computing lessons for careful independent study.

Degree Level Programmes · Formal Computing Foundations · Lesson 9

Function Properties: Domain, Range, Composition and Inverses

Use formal function properties to reason about transformations.

Lesson overview

Use formal function properties to reason about transformations.

CourseFundamentals of Computing
Topic strandFunctions
Assessment styleDigital exam practice
EvidenceWorked answer plus justification

Starter: make the model explicit

Before reading the worked example, write down the objects involved, the claim being made and the notation you expect to use. This prevents the common error of calculating before modelling.

Learning objectives

  • Distinguish domain, codomain and range.
  • Compose two functions in the correct order.
  • State when an inverse function can exist.

Learning outcomes

  • By the end of this lesson, you can distinguish domain, codomain and range.
  • By the end of this lesson, you can compose two functions in the correct order.
  • By the end of this lesson, you can state when an inverse function can exist.

Key vocabulary

rangecompositioninversemapping

What this lesson is about

Domain is the set of permitted inputs. Codomain is the set of outputs the function is declared to land in. Range is the set of outputs actually produced.

Composition connects functions in sequence, while an inverse reverses a mapping when reversal is well-defined. These properties matter whenever data is transformed through a pipeline.

Terms, acronyms and named methods

These are the phrases and named techniques used in this lesson. Read this section before the worked example so the notation and examples have a clear meaning.

CompositionNamed operation. Combining functions so that the output of one becomes the input of another. In g ∘ f, apply f first, then g.
Inverse functionPhrase. A function that reverses another function. It exists as a function only when each output corresponds to exactly one input.
RangePhrase. The set of outputs actually produced by a function from its domain.

Formal notation and definitions

(g ∘ f)(x) = g(f(x)).range(f) = {f(x) | x ∈ domain(f)}.f⁻¹ exists as a function only when f is bijective on the chosen domain and codomain.

How to read the symbols

dom(f)\operatorname{dom}(f)The domain of f: inputs for which f is defined.
range(f)\operatorname{range}(f)The actual outputs produced by f.
gfg\circ fComposition: apply f first, then apply g to the result.
f1f^{-1}An inverse function, when each output corresponds to exactly one input.

Use composition notation to show the order of transformations. The inner function is applied first, even though it is written on the right.

Degree-level reasoning

A function is a rule with a contract: each domain element has exactly one output. Many computing bugs come from leaving the domain or codomain vague.

Properties such as injective and surjective only make sense relative to the specified domain and codomain.

Do not stop at a correct-looking answer. State why the method is valid, whether the result depends on a hidden assumption, and what would count as a counterexample.

Worked formal model

This section shows the model, notation, calculation and interpretation as one worked answer. The notation is part of the reasoning, not decoration.

1. Context and objects

If normalise maps raw marks to percentages and grade maps percentages to labels, grade after normalise gives a full mark-to-grade transformation.

Objects: the domain, codomain, range, functions f and g, and the composed mapping g ∘ f.

Model cue: Use a pipeline diagram: x enters f, f(x) enters g, and g(f(x)) exits. This makes composition order visible.

2. Mathematical working

f:AB,g:BCf:A\to B,\quad g:B\to C(gf)(x)=g(f(x))(g\circ f)(x)=g(f(x))range(f)={f(x)xA}\operatorname{range}(f)=\{f(x)\mid x\in A\}
Plain text version
(g ∘ f)(x) = g(f(x)).
range(f) = {f(x) | x ∈ domain(f)}.
f⁻¹ exists as a function only when f is bijective on the chosen domain and codomain.

Worked use: If f converts a raw mark to a percentage and g converts a percentage to a grade band, then (g ∘ f)(x) gives the grade band for raw mark x. The reverse composition may be meaningless because a grade band is not a raw mark.

3. How to read the working

  1. Read f: A → B and g: B → C as a pipeline whose middle type B matches exactly.
  2. In (g ∘ f)(x), apply f first even though it is written on the right, then apply g to f(x).
  3. Read range(f) as the actual outputs produced, not every value in the codomain B.
  4. Check whether the reverse composition is defined before using it. f ∘ g may fail if g's output is not in f's domain.

4. Computing meaning and check

Composition models a data pipeline. If the output of one stage is not in the input domain of the next, the composed function is not well-defined.

Now check: Give an example where g ∘ f is defined but f ∘ g is not. State the domain and codomain for each function.

Worked example

From scenario to formal reasoning

Scenario: If normalise maps raw marks to percentages and grade maps percentages to labels, grade after normalise gives a full mark-to-grade transformation.

Method: Use the definitions and notation introduced above, then state what the result means in this computing scenario.

Reveal model answer

If f converts a raw mark to a percentage and g converts a percentage to a grade band, then (g ∘ f)(x) gives the grade band for raw mark x. The reverse composition may be meaningless because a grade band is not a raw mark.

Worked solution structure

How a strong answer should be written

  1. Define: State the domain and the objects under discussion. For this lesson, begin from (g ∘ f)(x) = g(f(x)).
  2. Apply: Use the relevant definition from functions; do not rely on the diagram, wording or intuition alone.
  3. Check: Test a boundary case, counterexample candidate or representation limit.
  4. Conclude: Write one sentence that connects the formal result back to the computing scenario.

Common misconception

A common mistake is reversing composition order. The function applied nearest the input happens first.

Guided practice

  1. Give functions f: A → B and g: B → C where g ∘ f is defined, then compute (g ∘ f)(x) for one input.
  2. Give an example where f ∘ g is not defined because the codomain/domain contract does not match.
  3. For f(x) = x² on integers with codomain non-negative integers, explain whether f is injective.
  4. State a domain restriction that would make a squaring function reversible.

Quick checks

1. In (g ∘ f)(x), which function is applied first?

2. An inverse function exists on the chosen domain and codomain only when the function is:

Digital exam practice

Example exam task

Let f convert a raw mark x out of 40 into a percentage using f(x) = 2.5x, and let g convert a percentage into a grade band. Calculate (g ∘ f)(32), explain why the reverse composition may be undefined, and state when an inverse can exist.

Notation toolkit

f:ABf:A\to B

Means: f accepts inputs from A and returns outputs in B

How to use: Use it to state a function's type contract.

gfg\circ f

Means: composition: apply f first, then g

How to use: Use it for pipelines of transformations.

f1f^{-1}

Means: an inverse function, when it exists

How to use: Use it only after checking the mapping is reversible on the stated domain and codomain.

What a good answer is expected to show

A strong answer for this lesson defines the domain, codomain, range, functions f and g, and the composed mapping g ∘ f, applies the functions method with visible working, and finishes by interpreting the result in the computing scenario.

How to solve it

  1. Read f: A → B and g: B → C as a pipeline whose middle type B matches exactly.
  2. In (g ∘ f)(x), apply f first even though it is written on the right, then apply g to f(x).
  3. Read range(f) as the actual outputs produced, not every value in the codomain B.
  4. Check whether the reverse composition is defined before using it. f ∘ g may fail if g's output is not in f's domain.

Model answer

Reveal model answer
f:AB,g:BCf:A\to B,\quad g:B\to C(gf)(x)=g(f(x)),(gf)(32)=g(80)(g\circ f)(x)=g(f(x)),\quad (g\circ f)(32)=g(80)f1 exists as a function only when f is bijective on the chosen domain and codomainf^{-1}\text{ exists as a function only when }f\text{ is bijective on the chosen domain and codomain}

Let f map a raw mark x out of 40 to a percentage, f(x) = 2.5x, and let g map percentages to grade bands. Then (g ∘ f)(32) applies f first to get 80, then applies g to get the grade band. The reverse composition may be undefined because a grade band is not a raw mark. An inverse requires a bijection on the chosen domain and codomain.

Practise next

  1. Give functions f: A → B and g: B → C where g ∘ f is defined, then compute (g ∘ f)(x) for one input.
  2. Give an example where f ∘ g is not defined because the codomain/domain contract does not match.

Self-marking criteria

  • States domain and codomain for each function.
  • Applies f before g in g ∘ f.
  • Checks the type/domain contract for the reverse composition.
  • Distinguishes range from codomain.
  • States bijectivity on the chosen domain/codomain for inverses.

Extension

Change one assumption in the worked scenario and decide whether the same method still applies. If it does not, name the exact point where the reasoning breaks.

Study route

Save one clean worked answer from this lesson. Include the problem statement, notation, working, final answer and a short note explaining the computing meaning of the result.

Next lesson: Vectors as Data, Geometry and State.