Functions Can Act on One Another
So far, we have treated a function mainly as a mapping from inputs to outputs.
Now we take the next step: functions themselves can be combined.
Suppose
\[ f:A\to B \]and
\[ g:B\to C. \]An input can first pass through \(f\), producing an element of \(B\), and then pass through \(g\), producing an element of \(C\).
\[ A \overset{f}{\longrightarrow} B \overset{g}{\longrightarrow} C \]That chained mapping is called a composition.
If a function can be reversed perfectly, the reversing function is its inverse.
And if a function sends every element to itself, it is an identity function.
Together, these ideas let us describe doing something, undoing it, and doing nothing at all.
Identity Functions
An identity function leaves every input unchanged.
On a set \(A\), the identity function is commonly written
\[ \operatorname{id}_A:A\to A \]and defined by
\[ \boxed{ \operatorname{id}_A(a)=a \quad \text{for every }a\in A } \]For the real numbers, we may write
\[ \operatorname{id}_{\mathbb{R}}(x)=x. \]Why Identity Matters
The identity function plays a role similar to identity elements in arithmetic.
Adding \(0\) leaves a number unchanged:
\[ x+0=x. \]Multiplying by \(1\) leaves a number unchanged:
\[ x\cdot1=x. \]Likewise, composing with an identity function leaves a compatible function unchanged.
\[ f\circ\operatorname{id}_A=f \]and
\[ \operatorname{id}_B\circ f=f \]when
\[ f:A\to B. \]Identity functions therefore provide the neutral element for composition.
Composite Functions
Suppose
\[ f:A\to B \]and
\[ g:B\to C. \]The composition of \(g\) with \(f\) is written
\[ g\circ f. \]It means:
Apply \(f\) first, then apply \(g\).
Formally,
\[ \boxed{ (g\circ f)(x)=g(f(x)) } \]The composite function maps directly from \(A\) to \(C\):
\[ g\circ f:A\to C. \]Example
Let
\[ f(x)=2x+1 \]and
\[ g(x)=x^2. \]Then
\[ (g\circ f)(x) = g(f(x)). \]Substitute \(f(x)=2x+1\) into \(g\):
\[ g(f(x)) = (2x+1)^2. \]Therefore,
\[ \boxed{ (g\circ f)(x)=(2x+1)^2 } \]Order of Composition
Composition is generally not commutative.
That means
\[ g\circ f \]and
\[ f\circ g \]usually produce different functions.
Using
\[ f(x)=2x+1 \]and
\[ g(x)=x^2, \]we found
\[ (g\circ f)(x) = (2x+1)^2. \]Now reverse the order:
\[ (f\circ g)(x) = f(g(x)). \]Since
\[ g(x)=x^2, \]we obtain
\[ f(g(x)) = 2x^2+1. \]Thus
\[ \boxed{ (g\circ f)(x)\neq(f\circ g)(x) } \]in general.
Read from Right to Left
The notation
\[ g\circ f \]is easiest to read operationally from right to left:
\[ x \overset{f}{\longmapsto} f(x) \overset{g}{\longmapsto} g(f(x)). \]This is similar to nested parentheses: the inside operation happens first.
Domain and Codomain Compatibility
Not every pair of functions can be composed in every order.
For
\[ g\circ f \]to make sense, outputs from \(f\) must be valid inputs for \(g\).
If
\[ f:A\to B \]and
\[ g:B\to C, \]the match is automatic because \(f\) lands in the set from which \(g\) accepts inputs.
A More General Condition
Composition can still work when the entire codomain of \(f\) is not literally the domain of \(g\), provided the outputs that actually occur lie inside the domain of \(g\).
A practical condition is
\[ \operatorname{Ran}(f) \subseteq \operatorname{Dom}(g). \]Whenever this condition holds,
\[ g(f(x)) \]is defined for every permitted input \(x\) of \(f\).
Example
Suppose
\[ f(x)=x^2 \]and
\[ g(x)=\sqrt{x}. \]Although \(\sqrt{x}\) is not real-valued for negative real inputs, the outputs of \(f(x)=x^2\) are always nonnegative.
Therefore,
\[ g(f(x)) = \sqrt{x^2} \]is defined for every real \(x\).
Evaluating Composite Functions
A composite can be evaluated one stage at a time.
Suppose
\[ f(x)=3x-2 \]and
\[ g(x)=x^2+1. \]Find
\[ (g\circ f)(4). \]First evaluate \(f\):
\[ f(4)=3(4)-2=10. \]Then apply \(g\):
\[ g(10)=10^2+1=101. \]Therefore,
\[ \boxed{ (g\circ f)(4)=101 } \]Equivalent Direct Substitution
We could also first find the composite rule:
\[ (g\circ f)(x) = (3x-2)^2+1. \]Then substitute \(x=4\):
\[ (g\circ f)(4) = (10)^2+1 = 101. \]Both methods describe the same mapping.
Inverse Functions
An inverse function reverses the action of a function.
If
\[ f(a)=b, \]then the inverse satisfies
\[ f^{-1}(b)=a. \]In mapping form,
\[ a \overset{f}{\longmapsto} b \]becomes
\[ b \overset{f^{-1}}{\longmapsto} a. \]The domain and codomain switch roles.
If
\[ f:A\to B \]is bijective, then
\[ f^{-1}:B\to A. \]Inverse as Reversed Ordered Pairs
If a function contains the ordered pair
\[ (a,b), \]its inverse contains
\[ (b,a). \]This matches the earlier definition of inverse relations, with one important addition: for the inverse relation to be a function on the entire codomain, the original function must be bijective.
When Does an Inverse Function Exist?
A function has an inverse function from its entire codomain back to its entire domain exactly when it is bijective.
That means the function must be both injective and surjective.
Why Injectivity Is Required
Suppose
\[ f(a)=c \]and
\[ f(b)=c \]with
\[ a\neq b. \]Reversing the mapping would require
\[ c\mapsto a \]and
\[ c\mapsto b. \]One input to the inverse would have two different outputs, so the inverse would fail to be a function.
Why Surjectivity Is Required
If some element of the codomain is never reached by \(f\), then after reversing the direction that element would become an input with no output.
Therefore a full inverse
\[ f^{-1}:B\to A \]requires every element of \(B\) to be reached.
Finding an Inverse Algebraically
For a bijective real-valued function written as
\[ y=f(x), \]a standard algebraic method is:
- write \(y=f(x)\),
- interchange \(x\) and \(y\),
- solve for \(y\),
- rename the result \(f^{-1}(x)\).
Example
Let
\[ f(x)=3x+5. \]Write
\[ y=3x+5. \]Swap \(x\) and \(y\):
\[ x=3y+5. \]Solve for \(y\):
\[ x-5=3y, \] \[ y=\frac{x-5}{3}. \]Therefore,
\[ \boxed{ f^{-1}(x)=\frac{x-5}{3} } \]Interpretation
The original function multiplies by \(3\) and then adds \(5\).
The inverse reverses those operations in reverse order:
- subtract \(5\),
- then divide by \(3\).
This “undo in reverse order” idea is a useful practical way to think about inverse functions.
Inverse and Identity Relationships
A function and its inverse undo one another.
If
\[ f:A\to B \]is bijective, then
\[ f^{-1}:B\to A. \]Composing first with \(f\) and then with \(f^{-1}\) returns the original element of \(A\):
\[ \boxed{ f^{-1}\circ f = \operatorname{id}_A } \]Likewise, composing first with \(f^{-1}\) and then with \(f\) returns the original element of \(B\):
\[ \boxed{ f\circ f^{-1} = \operatorname{id}_B } \]Element-by-Element View
If
\[ a\in A, \]then
\[ f^{-1}(f(a))=a. \]If
\[ b\in B, \]then
\[ f(f^{-1}(b))=b. \]These equations are the cleanest algebraic expression of the idea that inverse functions undo one another.
Inverse Function versus Reciprocal
The notation
\[ f^{-1} \]does not mean the reciprocal of \(f\).
The reciprocal of a function value is
\[ \frac{1}{f(x)}. \]The inverse function is
\[ f^{-1}(x). \]These are different concepts.
Example
Let
\[ f(x)=2x+1. \]The reciprocal expression is
\[ \frac{1}{f(x)} = \frac{1}{2x+1}. \]But the inverse function is found by reversing the mapping:
\[ f^{-1}(x) = \frac{x-1}{2}. \]Therefore,
\[ \boxed{ f^{-1}(x) \neq \frac{1}{f(x)} } \]in general.
The superscript \(-1\) indicates inverse mapping here, not numerical reciprocal.
Graphs of Inverse Functions
If
\[ (a,b) \]belongs to the graph of \(f\), then
\[ (b,a) \]belongs to the graph of \(f^{-1}\).
So the coordinates are exchanged.
Geometrically, exchanging \(x\) and \(y\) reflects a graph across the line
\[ y=x. \]Therefore, the graphs of a function and its inverse are mirror images across
\[ y=x. \]Why the Horizontal-Line Test Appears
A function must pass the vertical-line test.
After reflection across \(y=x\), vertical and horizontal directions switch.
Therefore, the original function must pass the horizontal-line test if its inverse relation is to pass the vertical-line test and become a function.
This is the graphical connection between injectivity and invertibility.
Longer Function Chains
Composition can involve more than two functions.
If
\[ f:A\to B, \qquad g:B\to C, \qquad h:C\to D, \]then we may form
\[ h\circ g\circ f. \]Operationally,
\[ A \overset{f}{\longrightarrow} B \overset{g}{\longrightarrow} C \overset{h}{\longrightarrow} D. \]Composition is associative:
\[ \boxed{ h\circ(g\circ f) = (h\circ g)\circ f } \]So we do not need to worry about how a chain of compositions is grouped, provided the domain and codomain connections are valid.
Order Still Matters
Associativity does not mean commutativity.
We may regroup compatible compositions, but we may not generally reverse their order.
Practical Applications
Unit Conversion Chains
Suppose one function converts miles to kilometers and another converts kilometers to meters.
Their composition converts miles directly to meters.
\[ \text{miles} \longrightarrow \text{kilometers} \longrightarrow \text{meters} \]The composite function packages the full conversion into one mapping.
Data Processing Pipelines
A software pipeline might
- parse raw input,
- normalize the data,
- calculate a result,
- format the output.
Each stage can be viewed as a function, and the complete pipeline as a composition of functions.
Encoding and Decoding
If an encoding function is bijective, a decoding function can act as its inverse.
\[ \text{original data} \overset{f}{\longrightarrow} \text{encoded data} \overset{f^{-1}}{\longrightarrow} \text{original data} \]This is the same structural idea as doing and undoing a reversible transformation.
Pricing and Tax
Suppose
\[ p(q) \]calculates a base price from quantity \(q\), while
\[ t(x) \]adds tax to a price \(x\).
Then
\[ (t\circ p)(q) \]calculates the final taxed price directly from the quantity.
Coordinate Transformations
Geometric transformations such as translations, rotations, reflections, and scalings can often be composed.
If each transformation is invertible, the entire chain can be undone by applying the inverse transformations in reverse order.
Worked Examples
Example 1: Find a Composite Rule
Let
\[ f(x)=x+4 \]and
\[ g(x)=3x. \]Then
\[ (g\circ f)(x) = g(x+4). \]So
\[ (g\circ f)(x) = 3(x+4) = 3x+12. \]Therefore,
\[ \boxed{ (g\circ f)(x)=3x+12 } \]Example 2: Reverse the Composition
Using the same functions,
\[ (f\circ g)(x) = f(3x). \]Therefore,
\[ (f\circ g)(x) = 3x+4. \]So
\[ g\circ f \neq f\circ g. \]Example 3: Evaluate a Composite
Let
\[ f(x)=x-1, \qquad g(x)=x^2. \]Find
\[ (g\circ f)(5). \]First,
\[ f(5)=4. \]Then,
\[ g(4)=16. \]Therefore,
\[ \boxed{ (g\circ f)(5)=16 } \]Example 4: Find an Inverse
Let
\[ f(x)=5x-2. \]Write
\[ y=5x-2. \]Swap \(x\) and \(y\):
\[ x=5y-2. \]Solve:
\[ x+2=5y, \] \[ y=\frac{x+2}{5}. \]Thus
\[ \boxed{ f^{-1}(x)=\frac{x+2}{5} } \]Example 5: Verify an Inverse
Using
\[ f(x)=5x-2 \]and
\[ f^{-1}(x)=\frac{x+2}{5}, \]compute
\[ f^{-1}(f(x)). \] \[ f^{-1}(5x-2) = \frac{(5x-2)+2}{5}. \] \[ f^{-1}(f(x)) = \frac{5x}{5} = x. \]Therefore,
\[ f^{-1}\circ f = \operatorname{id}_{\mathbb{R}}. \]Example 6: Restrict Before Inverting
The function
\[ f:\mathbb{R}\to[0,\infty), \qquad f(x)=x^2 \]is not injective, so it does not have an inverse function on all real inputs.
Restrict the domain:
\[ g:[0,\infty)\to[0,\infty), \qquad g(x)=x^2. \]Now \(g\) is bijective, and its inverse is
\[ \boxed{ g^{-1}(x)=\sqrt{x} }. \]The domain restriction removes the ambiguity between positive and negative square roots.
Common Errors
1. Applying Composition in the Wrong Order
In
\[ g\circ f, \]apply \(f\) first and \(g\) second.
2. Assuming Composition Is Commutative
In general,
\[ g\circ f \neq f\circ g. \]3. Ignoring Domain Compatibility
The outputs of the first function must be valid inputs for the second.
4. Assuming Every Function Has an Inverse Function
A full inverse function requires bijectivity.
A non-injective function produces ambiguity when reversed, and a non-surjective function leaves some reversed inputs unmapped.
5. Confusing \(f^{-1}(x)\) with \(1/f(x)\)
Inverse functions and reciprocals are different concepts.
6. Swapping \(x\) and \(y\) without Checking Invertibility
The algebraic swap-and-solve procedure can produce an inverse relation even when the original function is not one-to-one.
Before calling the result an inverse function, verify that the original mapping is invertible on the stated domain and codomain.
7. Forgetting to Reverse the Order of Operations
If a function performs several reversible operations in sequence, its inverse must undo them in reverse order.
Practice
Composition
Let
\[ f(x)=2x+1 \]and
\[ g(x)=x-4. \]Find:
- \((g\circ f)(x)\)
- \((f\circ g)(x)\)
Check Answers
- \[ (g\circ f)(x) = g(2x+1) = 2x+1-4 = \boxed{2x-3}. \]
- \[ (f\circ g)(x) = f(x-4) = 2(x-4)+1 = \boxed{2x-7}. \]
Evaluate a Composite
Let
\[ f(x)=x^2 \]and
\[ g(x)=x+2. \]Find
\[ (f\circ g)(3). \]Check Answer
First,
\[ g(3)=5. \]Then,
\[ f(5)=25. \]Therefore,
\[ \boxed{ (f\circ g)(3)=25 }. \]Find an Inverse
Find the inverse of
\[ f(x)=4x+7. \]Check Answer
Start with
\[ y=4x+7. \]Swap:
\[ x=4y+7. \]Solve:
\[ y=\frac{x-7}{4}. \]Therefore,
\[ \boxed{ f^{-1}(x)=\frac{x-7}{4} }. \]Verify the Identity
Using
\[ f(x)=4x+7 \]and
\[ f^{-1}(x)=\frac{x-7}{4}, \]show that
\[ f(f^{-1}(x))=x. \]Check Answer
\[ f\left(\frac{x-7}{4}\right) = 4\left(\frac{x-7}{4}\right)+7. \] \[ =x-7+7. \] \[ \boxed{x}. \]Inverse or Reciprocal?
Let
\[ f(x)=2x+5. \]Write:
- the reciprocal expression \(1/f(x)\),
- the inverse function \(f^{-1}(x)\).
Check Answers
- \[ \frac{1}{f(x)} = \frac{1}{2x+5}. \]
- \[ f^{-1}(x) = \frac{x-5}{2}. \]
These are different expressions with different meanings.
The Deeper Idea
Identity, inverse, and composition give functions an algebraic structure of their own.
Composition lets mappings be chained:
\[ A \overset{f}{\longrightarrow} B \overset{g}{\longrightarrow} C. \]Identity leaves a mapping unchanged:
\[ f\circ\operatorname{id} = \operatorname{id}\circ f = f. \]An inverse reverses a suitable mapping:
\[ f^{-1}\circ f = \operatorname{id}. \]These ideas echo familiar arithmetic structure:
- identity elements leave something unchanged,
- inverse operations undo one another,
- and composition combines operations into a larger process.
But functions make the structure more general because the objects being moved can be numbers, points, vectors, matrices, sets, records, geometric figures, or other mathematical objects.
\[ \boxed{ \text{do} \longrightarrow \text{compose} \longrightarrow \text{undo} } \]This viewpoint will become increasingly important in transformations, algebraic structures, matrices, calculus, and higher mathematics.
Summary
- The identity function on \(A\) is \[ \operatorname{id}_A(a)=a. \]
- For \[ f:A\to B, \] identity composition satisfies \[ f\circ\operatorname{id}_A=f \] and \[ \operatorname{id}_B\circ f=f. \]
- The composition of \(g\) with \(f\) is \[ (g\circ f)(x)=g(f(x)). \]
- In \(g\circ f\), apply \(f\) first and \(g\) second.
- Composition is generally not commutative: \[ g\circ f\neq f\circ g. \]
- Composition is associative: \[ h\circ(g\circ f)=(h\circ g)\circ f. \]
- For \(g\circ f\) to be defined, outputs of \(f\) must be valid inputs for \(g\).
- A bijective function \[ f:A\to B \] has an inverse \[ f^{-1}:B\to A. \]
- The inverse reverses ordered pairs and mappings.
- A function and its inverse satisfy \[ f^{-1}\circ f=\operatorname{id}_A \] and \[ f\circ f^{-1}=\operatorname{id}_B. \]
- The inverse-function notation \[ f^{-1}(x) \] does not mean \[ \frac{1}{f(x)}. \]
- The graphs of a function and its inverse are reflections across \[ y=x. \]
Identity, inverse, and composition turn functions from isolated rules into a system of reusable mappings. We can chain functions into larger processes, recognize when a mapping can be reversed, and use identity functions to describe when nothing has changed.
Sets, Relations, and Functions
- Previous: Injective, Surjective, and Bijective Functions
- Sets, Relations, and Functions — return to the lesson directory.