Welcome to your sixth lesson in the "Foundations of Algebra and Functions" module. In our previous session, we developed a powerful shorthand for handling long sequences of computations with summation and product notation. Today, we shift our focus from operating on lists of numbers to operating on functions themselves. We will explore two fundamental concepts: function composition, which is how we chain functions together, and function inverses, which is how we "undo" a function's action.
Your goal of conducting research in machine learning requires a deep understanding of how complex models are constructed. A deep neural network, for example, is nothing more than a giant composite function, where the output of one layer of functions becomes the input to the next. Similarly, understanding inverses is crucial for many data transformation and normalization techniques. This lesson lays the conceptual groundwork for these advanced applications.
Our objective is to learn how to compute the composition of two functions and how to find and verify the inverse of a function.
Combining Functions: Composition
Imagine a process as an assembly line. One machine takes a raw material and processes it, and a second machine takes the output of the first and processes it further. This is the core idea of function composition. We take an input, apply a function to it, and then apply a second function to the result of the first.
Let's say we have a function that takes an input and produces an output , so . Then, a second function takes as its input and produces a final output , so . By chaining these together, we create a new function that directly relates to :
This new function is called the composite function. We use the notation to represent this composition, read as "f composed with g". Thus, . Note the order: the function on the right, , is applied first. It is the "inner" function.
The following resource provides a clear introduction to this concept, complete with algebraic examples, and discusses the important roles of the domain and codomain.
This reading introduces the concept of composing functions, the notation used, and how to think about the domains and codomains of the resulting composite function.
Please read the Introduction to grasp the core idea. Then, study the section on Composing two functions, paying close attention to Definition 1.6.2 and the discussion of "inner" and "outer" functions. You can skim the activities for now, but do read the Summary at the end to consolidate the main points.
A crucial point, which you might have already inferred, is that function composition is generally not commutative. That is, is usually not the same as . Going back to our assembly line, the final product likely depends on which machine comes first.
To explore the properties of composition with more rigor, the following video discusses it from a set-theoretic perspective, which aligns well with your preference for formal reasoning.
Composition of Functions (Set Theory)
This video provides a more formal definition of function composition, illustrates why it is not commutative, and proves that it is associative.
Watch the first segment from the beginning to the machine analogy for a solid conceptual and formal definition. Then, watch the segment on non-commutativity to understand why order matters. Finally, the proof of associativity shows that for a chain of functions like h(g(f(x))), the grouping doesn't matter: (h \circ g) \circ f = h \circ (g \circ f). This property is what allows us to think of a neural network as a single, deep composition without worrying about parentheses.
Reversing Functions: Inverses
Just as we can combine functions, we can also seek to "undo" them. If a function maps an input to an output , its inverse function, denoted , does the reverse: it maps back to .

This "undoing" relationship can be expressed perfectly using the language of composition. If is the inverse of , then applying and then should get you right back where you started.
Similarly, applying and then also brings you back to the original input.
In the notation of composition, if we call the "do-nothing" function the identity function , then these conditions are and .
The following resource provides a formal, proof-based treatment of inverse functions, which you should find satisfying.
This document defines inverse functions rigorously and connects the definition to function composition.
Start by reading the formal definition of an inverse function. Then, study Theorem 1 and Corollary 3, which restate this definition using the language of composition and the identity function. Finally, read Corollary 5, which summarizes these properties using the standard f^{-1} notation.
When Does an Inverse Exist?
Not every function can be inverted. For an inverse to exist, the original function must be a bijection—that is, it must be both one-to-one (injective) and onto (surjective).
- One-to-one (injective): Each output is produced by exactly one input. If a function is not one-to-one (e.g., , where both and map to ), its inverse would be ambiguous. Should the inverse of 4 be 2 or -2? A function can only have one output for a given input.
- Onto (surjective): Every possible element in the codomain is an actual output. If a function is not onto, there would be elements in the codomain for which the inverse function is not defined.
The PDF Inverse Functions provides a formal proof for this crucial fact.
This section formally proves the condition for a function's invertibility.
Please read Theorem 6, which states: "A function is invertible if and only if it is bijective." The proof demonstrates precisely why injectivity and surjectivity are necessary and sufficient conditions.
Finding and Visualizing Inverses
For a function that is invertible, we can find its inverse using a simple algebraic procedure:
- Replace with .
- Swap the variables and . This represents the reversal of roles: the input becomes the output and vice versa.
- Solve the new equation for .
- The resulting expression for is the inverse function, .
Example: Let's find the inverse of .
- Therefore, .
This algebraic swap of and has a beautiful geometric counterpart. The graph of is the reflection of the graph of across the line .

Properties of Inverses
Finally, two important properties link inverses and composition.
- Inverse of an Inverse: The inverse of an inverse is the original function. . This is intuitive: undoing the "undo" operation takes you back to the original.
- Inverse of a Composition: The inverse of a composition is the composition of the inverses in the reverse order: . This is often called the "socks and shoes" rule. To reverse the process of putting on socks then shoes, you must first take off your shoes, then your socks.
The formal proofs for these properties are also available in the Inverse Functions PDF.
This final reading from the PDF covers two key properties of inverses.
Please review Theorem 7 for the inverse of an inverse property and Theorem 8 for the inverse of a composition property.
Conclusion
In this lesson, we have added two powerful operations to our functional toolkit. We learned how to build complex functions by chaining simpler ones together (composition) and how to reverse a function's process by finding its inverse.
Key Takeaways:
- Function Composition combines two functions, and , into a new function defined by . The order of operations matters, and composition is generally not commutative.
- An Inverse Function, , "undoes" the action of a function , satisfying and .
- A function has an inverse if and only if it is bijective (both one-to-one and onto).
- The graph of an inverse function is the reflection of the original function's graph across the line .
- The inverse of a composition follows the "socks and shoes" rule: .
With these concepts, we have concluded our foundational review of algebra and functions. In the next lesson, we will make a significant transition into the world of calculus, starting with the concept of limits. Limits are the bedrock upon which all of calculus is built, allowing us to analyze how functions behave as inputs approach a specific value.