Fact-checked by Grok 2 weeks ago

Function composition

In , function composition is an that combines two f: X \to Y and g: Y \to Z to form a new function g \circ f: X \to Z, defined by (g \circ f)(x) = g(f(x)) for all x \in X, where the output of the inner function f serves as the input to the outer function g. This process chains the functions, enabling the construction of complex mappings from simpler ones, provided the codomain of f matches or is a of the domain of g. Function composition exhibits key properties that underpin its utility across mathematical structures. It is associative, meaning (h \circ g) \circ f = h \circ (g \circ f) for compatible functions f, g, and h, allowing parentheses to be omitted in chains without ambiguity. However, it is generally non-commutative, as g \circ f \neq f \circ g unless the functions satisfy specific conditions, such as when one is the identity. Each set admits identity functions that act as neutral elements under composition, preserving the original function when composed. Beyond basic , function composition plays a central role in diverse fields. In , it motivates the chain rule for : if y = f(g(x)), then \frac{dy}{dx} = f'(g(x)) \cdot g'(x), facilitating derivatives of composite functions. In , composition of morphisms generalizes the concept across abstract structures, with sets and functions forming the category Set where arrows are functions and composition follows the standard rule. In , it enables modular code construction by piping outputs of pure functions as inputs to others, as seen in languages like with the . operator for (f . g) x = f (g x).

Fundamentals

Definition

In mathematics, a function is a mapping that assigns to each element in a set (the domain) a unique element in another set (the codomain). For the composition of two functions to be well-defined, the codomain of the first function must match the domain of the second, ensuring that the output of the first lies within the input set of the second. This prerequisite guarantees that the composition operates consistently across the entire domain of the initial function. Given functions f: Y \to Z and g: X \to Y, their , denoted f \circ g: X \to Z, is the defined by (f \circ g)(x) = f(g(x)) for all x \in X. This chains the mappings, where the result of applying g to x serves as the input to f. In the case of partial functions, where the domain of definition is a proper of the intended , the composition f \circ g is defined only on the subset of X such that g(x) falls within the domain of f, resulting in a potentially non-total . This restriction ensures the remains meaningful, though it may exclude some elements from the original . The concept of function composition originated in 18th-century , with providing an early description in 1718 as a quantity formed by combining a with constants in any manner. Leonhard Euler further developed it in his 1748 work , solidifying its role in analytic expressions by defining functions in terms of analytic expressions composed from and constants.

Notation

The standard notation for the composition of two functions f and g is the circle operator \circ (Unicode U+2218), defined such that (f \circ g)(x) = f(g(x)). This symbol, denoting the application of g followed by f, was introduced by the collective in their seminal series , with early documented usage appearing in a 1944 seminar report and formalized in the 1949 volume Fonctions d'une variable réelle. In certain mathematical contexts, particularly within and , function composition is instead denoted by simple , where fg(x) = f(g(x)). This convention treats functions as elements of a under composition and is widely adopted in treatments of groups and morphisms, emphasizing the operator-like nature of functions without an explicit symbol. The circle operator \circ has higher precedence than in standard mathematical conventions, meaning expressions like f \circ g \, x are parsed as (f \circ g)(x) = f(g(x)) rather than f(g(x)), avoiding the need for additional parentheses in chained compositions. Historically, the notation for function composition evolved from verbal descriptions in the —such as Euler's explicit writings of composite expressions like f(\phi(x))—to more symbolic representations in the , as the concept of functions became increasingly abstract and algebraic. This shift, driven by the rigorous development of by figures like Dirichlet and Weierstrass, paved the way for modern operator symbols, though no unified notation like \circ emerged until the structuralist approach of Bourbaki in the .

Examples

Unary Function Examples

A fundamental illustration of function composition involves basic arithmetic operations. Consider the unary functions g(x) = x + 1 and f(x) = x^2, both defined on the real numbers. The composition (f \circ g)(x) applies g first, yielding x + 1, and then f to that result, giving (x + 1)^2 = x^2 + 2x + 1. Another example combines transcendental functions: let g(x) = e^x and f(x) = \sin x, with domains and ranges ensuring the composition is well-defined for real x. Then (f \circ g)(x) = \sin(e^x). To evaluate step-by-step at x = 0, first compute g(0) = e^0 = 1, then f(1) = \sin 1 \approx 0.8415. Composition also demonstrates the effect of functions, which each other to produce the . For instance, with g(x) = e^x (defined for all real x, range positive reals) and f(x) = \log x (, domain positive reals), the (f \circ g)(x) = \log(e^x) = x for all real x, recovering the input unchanged. In geometric contexts, function chains linear transformations on the plane, such as followed by shifting. For example, a function g(x) = 2x stretches distances from the by a factor of 2, while a shifting function f(x) = x + 3 translates horizontally by 3 units; their (f \circ g)(x) = 2x + 3 first doubles the input and then shifts it, resulting in a combined that alters both scale and position.

Multivariate Examples

In multivariate function composition, functions map from and to spaces of higher dimensions, such as \mathbb{R}^n to \mathbb{R}^m, requiring the output of the inner function to match the input of the outer function for the composition to be well-defined. This extends the univariate case by handling vector inputs and outputs, often arising in and linear algebra applications. Consider the functions g: \mathbb{R}^2 \to \mathbb{R} defined by g(x, y) = x + y and f: \mathbb{R} \to \mathbb{R}^2 defined by f(z) = (z, z). The composition f \circ g: \mathbb{R}^2 \to \mathbb{R}^2 is given by (f \circ g)(x, y) = f(g(x, y)) = f(x + y) = (x + y, x + y), illustrating how the scalar output of g feeds into the vector-producing f. Linear transformations, represented by matrices, provide another key example of multivariate composition. For instance, let R be the rotation matrix by \theta degrees in \mathbb{R}^2, R = \begin{pmatrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end{pmatrix}, and S be the scaling matrix by factors a and b, S = \begin{pmatrix} a & 0 \\ 0 & b \end{pmatrix}. The composition S \circ R first rotates a vector and then scales it, with matrix S R, yielding S R = \begin{pmatrix} a \cos \theta & -a \sin \theta \\ b \sin \theta & b \cos \theta \end{pmatrix}. This matrix product corresponds to applying the transformations sequentially. In the context of differentiable multivariate functions, composition appears in the chain rule for partial derivatives. Suppose h: \mathbb{R}^2 \to \mathbb{R} is the outer function h(u, v) = u^2 + v, and g: \mathbb{R}^2 \to \mathbb{R}^2 is the inner function g(x, y) = (x y, y). The composite f = h \circ g: \mathbb{R}^2 \to \mathbb{R} is f(x, y) = (x y)^2 + y. The partial derivatives satisfy \frac{\partial f}{\partial x} = \frac{\partial h}{\partial u} \frac{\partial g_1}{\partial x} + \frac{\partial h}{\partial v} \frac{\partial g_2}{\partial x} = 2 (x y) (y) + 1 \cdot 0 = 2 x y^2, demonstrating how gradients of the outer function apply to the of the inner. A real-world application occurs in pipelines, where vector-valued signals undergo sequential transformations. For example, consider a filtering function f: \mathbb{R}^n \to \mathbb{R}^n that applies a to an n-channel \mathbf{x}, producing \mathbf{y} = f(\mathbf{x}), followed by an g: \mathbb{R}^n \to \mathbb{R}^n with g(\mathbf{y}) = k \mathbf{y} for gain k > 1. The g \circ f processes the raw signal through denoising before boosting, common in modular filter designs for audio or image data.

Properties

Associativity

Function composition exhibits the property of associativity. For functions f: C \to D, g: B \to C, and h: A \to B with compatible domains and codomains, the composition satisfies (f \circ g) \circ h = f \circ (g \circ h). This equality holds because both sides define the same mapping from the domain of h to the codomain of f. To verify, let x be in the domain of h. Then, ((f \circ g) \circ h)(x) = (f \circ g)(h(x)) = f(g(h(x))), and (f \circ (g \circ h))(x) = f((g \circ h)(x)) = f(g(h(x))). Since the outputs match for every x, the composed functions are identical. The associativity of function composition implies that multiple compositions can be written without parentheses, such as f \circ g \circ h, as the result is independent of grouping. This property is inherited from the more general composition of binary relations in set theory, which is also associative but differs slightly in that relations permit multiple outputs while functions do not. For a concrete verification, consider the arithmetic functions f(x) = x^2, g(x) = x + 1, and h(x) = 2x over the reals. At x = 1, ((f \circ g) \circ h)(1) = (f \circ g)(2) = f(3) = 9, and (f \circ (g \circ h))(1) = f((g \circ h)(1)) = f(g(2)) = f(3) = 9. The equality confirms associativity at this point, and it holds generally by the proof above.

Invertibility and Other Properties

A function composition f \circ g is invertible if and only if both f and g are invertible, provided the range of g lies within the domain of f. In this case, the inverse is given by (f \circ g)^{-1} = g^{-1} \circ f^{-1}. To verify this, substitute into the definition of the inverse: compute (f \circ g) \circ (g^{-1} \circ f^{-1}). First, the inner composition yields g \circ (g^{-1} \circ f^{-1}) = (g \circ g^{-1}) \circ f^{-1} = \mathrm{id}_B \circ f^{-1} = f^{-1}, where \mathrm{id}_B is the identity on the codomain of g. Then, f \circ f^{-1} = \mathrm{id}_C, the identity on the codomain of f. Similarly, (g^{-1} \circ f^{-1}) \circ (f \circ g) = \mathrm{id}_A. Thus, g^{-1} \circ f^{-1} serves as the two-sided inverse. Function composition is generally non-commutative, meaning f \circ g \neq g \circ f in most cases. For example, consider f(x) = x + 1 and g(x) = 2x over the real numbers. Then (f \circ g)(x) = 2x + 1, while (g \circ f)(x) = 2(x + 1) = 2x + 2, which differ for all x. A function f is idempotent under composition if f \circ f = f. Projection functions provide classic examples; for instance, in linear algebra, an orthogonal projection operator P onto a subspace satisfies P^2 = P, as applying the projection twice yields the same result as once. Composition preserves continuity: if g is continuous at a point and the range of g lies in the domain of f, where f is continuous at g(a), then f \circ g is continuous at a. Similarly, composition preserves differentiability: if g is differentiable at a and f is differentiable at g(a), with the range of g in the domain of f, then f \circ g is differentiable at a.

Iteration and Powers

Functional Iteration

Functional iteration refers to the repeated of a single with itself. For a f: X \to X where X is a set, the n-th iterate f^n is defined recursively as f^0(x) = x (the ) and f^{n+1}(x) = f(f^n(x)) for nonnegative integers n, with f^1 = f. This notation captures the process of applying f exactly n times to an input x \in X. A fixed point of f is an element x \in X satisfying f(x) = x, meaning the iterate f^n(x) = x for all n \geq 1. More generally, a of period n is a point x \in X such that f^n(x) = x but f^k(x) \neq x for all $1 \leq k < n, forming a cycle under iteration. These points are fundamental in analyzing the long-term behavior of iterates, as orbits under f^n may converge to fixed points, enter periodic cycles, or exhibit other dynamics. A classic example arises in chaos theory with the logistic map f(x) = r x (1 - x) for x \in [0,1] and parameter r \in (0,4]. For $1 < r < 3, iterations from most initial x converge to the stable fixed point x^* = 1 - 1/r. As r increases beyond 3, the fixed point destabilizes, leading to period-doubling bifurcations where stable cycles of period 2, 4, 8, and higher emerge; at an accumulation point r_\infty \approx 3.57, begins, with dense orbits and sensitive dependence on initial conditions, though periodic points persist densely in the interval. Convergence of the sequence of iterates \{f^n(x)\} to a fixed point occurs under certain conditions, such as when f is a on a complete metric space. The states that if there exists k \in (0,1) such that d(f(y), f(z)) \leq k \, d(y, z) for all y, z in the space (where d is the metric), then f has a unique fixed point p, and iterations from any initial x converge to p with rate |f^n(x) - p| \leq \frac{k^n}{1-k} |x - f(x)|. This guarantees global convergence for contractions, providing a foundational result for iterative methods in analysis.

Functional Powers

In the context of function composition, the integer powers of a function, known as functional powers, are defined through repeated self-composition. For a function f: X \to Y where Y \subseteq X, the n-th functional power f^n for a positive integer n is the n-fold composition f \circ f \circ \cdots \circ f (applied n times), so f^n(x) = f(f(\cdots f(x) \cdots)). This extends the base case of functional iteration to exponentiation within the semigroup of compositions, with f^1 = f and f^0 as the identity function. For functions that commute under composition (f \circ g = g \circ f), more general exponentiation can be approached using exponential or logarithmic mappings, though integer powers remain the primary focus as they directly correspond to iterated application. A significant extension of functional powers arises in the algebra of formal power series, where composition defines a ring structure under suitable conditions. Consider formal power series over a ring R, such as f(x) = \sum_{k=1}^\infty a_k x^k (with no constant term) and g(x) = \sum_{k=0}^\infty b_k x^k; their composition g \circ f yields another formal power series \sum_{k=0}^\infty c_k x^k, with coefficients determined recursively. When f includes a nonzero constant term, composition may not always exist as a formal power series, but necessary and sufficient conditions ensure it does, such as the series being invertible or satisfying specific valuation properties. A classic example is the composition \exp(x) \circ \sin(x) = \sum_{n=0}^\infty \frac{1}{n!} \left( \sin(x) \right)^n, which converges formally and illustrates how transcendental functions generate new series via powering and composition. This framework is foundational in algebraic analysis and generating function theory. Fractional functional powers generalize integer powers to non-integer exponents by solving associated functional equations. For a square root, one seeks a function h such that h \circ h = f, denoted h = f^{1/2}; more broadly, for rational p/q, (f^{p/q})^q = f^p. Real or fractional iterates f^\alpha satisfy f^\alpha \circ f^\beta = f^{\alpha + \beta} and f^1 = f, often constructed via \alpha(f(x)) = \alpha(x) + 1 or for linearization near fixed points. These solutions, typically real-analytic for suitable f, enable exponentiation in continuous iteration settings, as explored for exponentially growing functions like e^x. An application of integer functional powers appears in quantum mechanics through the time evolution operator. For a time-independent Hamiltonian \hat{H}, the unitary operator U(t) = e^{-i \hat{H} t / \hbar} evolves states via |\psi(t)\rangle = U(t) |\psi(0)\rangle. For integer n, this decomposes as U(t) = [U(t/n)]^n, where the power signifies n-fold composition of the operator, analogous to functional powering in the group of unitary transformations on Hilbert space. This structure underpins Trotter-Suzuki approximations for simulating evolution.

Algebraic Structures

Composition Monoids

In abstract algebra, the set of all functions from a nonempty set X to itself, denoted X^X, forms a monoid under the operation of function composition. The binary operation is defined by (f \circ g)(x) = f(g(x)) for all x \in X, which is associative, and the identity function \mathrm{id}_X, where \mathrm{id}_X(x) = x for all x \in X, serves as the unit element satisfying f \circ \mathrm{id}_X = \mathrm{id}_X \circ f = f for any f \in X^X. This structure is known as the full transformation monoid on X, and when X is finite with |X| = n, it contains exactly n^n elements. Within this monoid, the subset of all bijective functions from X to itself forms a submonoid consisting solely of invertible elements; this is the symmetric group on X, often denoted S_X or S_n when |X| = n. For instance, when X = \{1, 2, 3\}, the symmetric group S_3 comprises the six permutations of these elements and is itself a monoid under composition, with the identity permutation as the unit. More generally, any submonoid of the full transformation monoid arises from a subset of transformations closed under composition and containing the identity. Transformation monoids find significant applications in automata theory, where the set X represents the state space of a finite automaton, and elements of the monoid model transitions between states induced by input symbols, with composition corresponding to the sequential application of inputs. This perspective allows algebraic techniques to analyze automaton behavior. In abstract algebra, a semigroup is defined as a nonempty set equipped with an associative binary operation, forming an associative magma without necessarily requiring an identity element. Under function composition, the set of all functions from a finite set X to itself constitutes the full transformation semigroup T_X, where composition serves as the operation; this structure is associative by the properties of function composition. Similarly, the set of all endomorphisms of a vector space V over a field forms the endomorphism semigroup \mathrm{End}(V), consisting of linear maps V \to V closed under composition, which is associative. In transformation semigroups like T_X, Green's relations provide a classification of elements based on the principal ideals they generate. These include the left relation \mathcal{L}, where a \mathcal{L} b if S^1 a = S^1 b for the semigroup S with adjoined identity S^1; the right relation \mathcal{R}, where a \mathcal{R} b if a S^1 = b S^1; the two-sided relation \mathcal{J}, where a \mathcal{J} b if S^1 a S^1 = S^1 b S^1; the intersection \mathcal{H} = \mathcal{L} \cap \mathcal{R}; and the relation \mathcal{D} = \mathcal{L} \circ \mathcal{R}. In the context of finite transformation semigroups, the \mathcal{D}-relation particularly distinguishes elements by the size of their images (rank), linking transformations with equivalent domain-codomain behaviors through shared principal ideals generated by compositions. For instance, two transformations are \mathcal{D}-related if they produce isomorphic structures in terms of image sets and relational restrictions. Semigroup theory under function composition connects to combinatorics on words through functional graphs, where a function f: X \to X induces a directed graph with out-degree one at each vertex, and iterated compositions correspond to paths in this graph. Words over an alphabet can encode such paths, while the Cayley graph of a semigroup encodes words as paths, facilitating the study of free semigroups generated by alphabets under concatenation, akin to composition in transformation settings. This interplay appears in analyses of word avoidability and growth rates in subsemigroups of transformations.

Multivariate and Higher-Dimensional Composition

Composition of Multivariate Functions

In multivariable calculus, the composition of functions extends the unary case to mappings between Euclidean spaces of arbitrary dimensions. Consider functions g: X \to Y where X \subset \mathbb{R}^m and Y \subset \mathbb{R}^n, and f: Y \to Z where Z \subset \mathbb{R}^p. The composite function f \circ g: X \to Z is defined by (f \circ g)(\mathbf{x}) = f(g(\mathbf{x})) for \mathbf{x} \in X, provided the composition is well-defined on the relevant domains. For the composition to be defined pointwise, the image of g must be contained in the domain of f, ensuring that g(\mathbf{x}) lies within the domain of f for all \mathbf{x} \in X; however, g need not be surjective onto the domain of f, as the image of g only requires inclusion in that domain. This compatibility condition generalizes the domain restrictions in single-variable composition while accommodating vector inputs and outputs. The differentiability of composite multivariate functions is governed by an adaptation of the chain rule, expressed via Jacobian matrices. If g is differentiable at \mathbf{a} \in X and f is differentiable at g(\mathbf{a}), then f \circ g is differentiable at \mathbf{a}, with the Jacobian matrix satisfying D(f \circ g)(\mathbf{a}) = Df(g(\mathbf{a})) \cdot Dg(\mathbf{a}), where Dg(\mathbf{a}) is the n \times m Jacobian of g and Df(g(\mathbf{a})) is the p \times n Jacobian of f, and the product is matrix multiplication. A representative example arises in parametric representations, such as composing a map g: \mathbb{R}^2 \to \mathbb{R}^2 that distorts coordinates with an embedding f: \mathbb{R}^2 \to \mathbb{R}^3 that lifts to a surface; for instance, let g(x,y) = (x^2 - y^2, 2xy) and f(u,v) = (u, v, \sqrt{u^2 + v^2}), yielding f \circ g: \mathbb{R}^2 \to \mathbb{R}^3 that parametrizes a parabolic surface from planar inputs.

Vector-Valued and Matrix Composition

Vector-valued functions map from a domain such as \mathbb{R} or \mathbb{R}^k to a vector space like \mathbb{R}^n. Consider a function g: \mathbb{R} \to \mathbb{R}^n that produces a vector output for each scalar input, and f: \mathbb{R}^n \to \mathbb{R}^m that takes a vector input and yields another vector. The composition f \circ g: \mathbb{R} \to \mathbb{R}^m is defined by (f \circ g)(x) = f(g(x)), where the output vector of g serves as the input vector to f, provided the dimensions align such that the codomain of g matches the domain of f. This process applies component-wise, as each component of the output vector from g feeds into the corresponding input components of f. In the linear case, vector-valued functions correspond to linear transformations between Euclidean spaces, represented by matrices. For linear maps B: \mathbb{R}^p \to \mathbb{R}^n and A: \mathbb{R}^n \to \mathbb{R}^m with standard matrices B (an n \times p matrix) and A (an m \times n matrix), the composition A \circ B: \mathbb{R}^p \to \mathbb{R}^m has standard matrix AB, the matrix product. This satisfies (AB)\mathbf{v} = A(B\mathbf{v}) for any vector \mathbf{v} \in \mathbb{R}^p, confirming that matrix multiplication encodes the sequential application of transformations. Key properties of such compositions include those of the trace and determinant. The trace of the composite matrix AB equals the trace of BA (when both products are defined), reflecting the cyclic invariance under composition. For square matrices A, B \in \mathbb{R}^{n \times n}, the determinant satisfies \det(A \circ B) = \det(AB) = \det(A) \det(B), which geometrically indicates that the composition scales volumes (or areas in 2D) by the product of the individual scaling factors and preserves or reverses orientation based on the signs. In computer graphics, matrix compositions form transformation pipelines to manipulate 3D objects efficiently. A sequence of operations—such as scaling, rotation, and translation—is represented by multiplying corresponding 4×4 matrices (using homogeneous coordinates), with the rightmost matrix applied first; the resulting single matrix applies the full pipeline in one step, optimizing rendering in systems like .

Generalizations

Category Theory Perspective

In category theory, function composition is abstracted and generalized through the framework of categories, where the category of sets, denoted \mathbf{Set}, serves as a foundational example. In \mathbf{Set}, the objects are sets and the morphisms are functions between those sets, with composition of morphisms defined precisely as the standard function composition: for functions f: X \to Y and g: Y \to Z, the composite g \circ f: X \to Z is given by (g \circ f)(x) = g(f(x)) for all x \in X. This composition operation satisfies the axioms of associativity and the existence of identity morphisms (identity functions), making \mathbf{Set} a category in the sense introduced by Samuel Eilenberg and Saunders Mac Lane. Functoriality arises from the preservation of this composition under mappings between categories, known as functors. A functor F: \mathbf{C} \to \mathbf{D} between categories maps objects and morphisms while ensuring F(g \circ f) = F(g) \circ F(f), thus respecting the compositional structure. In diagrammatic terms, this manifests as horizontal composition, where sequences of morphisms in commutative diagrams represent paths of composition; for instance, in a diagram with parallel paths from an object A to C via intermediate objects, the equality of composites along each path enforces the functorial preservation of function composition. Such diagrams are central to verifying properties like commutativity, where horizontal juxtaposition of arrows denotes the sequential application akin to function chaining in \mathbf{Set}. At a higher level, natural transformations provide a notion of composition between functors themselves, treating them as "morphisms of morphisms." A natural transformation \alpha: F \Rightarrow G between functors F, G: \mathbf{C} \to \mathbf{D} assigns to each object X in \mathbf{C} a morphism \alpha_X: F(X) \to G(X) in \mathbf{D}, such that for any morphism f: X \to Y in \mathbf{C}, the diagram \begin{CD} F(X) @>{\alpha_X}>> G(X) \\ @V{F(f)}VV @VV{G(f)}V \\ F(Y) @>>{\alpha_Y}> G(Y) \end{CD} commutes, i.e., \alpha_Y \circ F(f) = G(f) \circ \alpha_X. This ensures a coherent, component-wise composition that generalizes function application across structures. Natural transformations compose vertically (stacking between the same pair of functors) or horizontally (via the Godement product, combining transformations between composed functors), extending the compositional paradigm beyond single morphisms. Universal properties further illuminate composition in categories like \mathbf{Set}, defining objects up to isomorphism via their morphisms. For example, the categorical product of objects A and B is an object P equipped with projection morphisms \pi_A: P \to A and \pi_B: P \to B, satisfying the universal property: for any object Q with morphisms f: Q \to A and g: Q \to B, there exists a unique morphism \langle f, g \rangle: Q \to P such that \pi_A \circ \langle f, g \rangle = f and \pi_B \circ \langle f, g \rangle = g. In \mathbf{Set}, P = A \times B with the standard projections, and the pairing \langle f, g \rangle composes the functions to embed into the Cartesian product, showcasing how composition mediates the "universal" mediating morphism. This property underscores composition's role in constructing limits and colimits, where projections or inclusions form the compositional backbone of generalized products.

Other Generalizations

Relation composition generalizes function composition to binary relations. Given binary relations R \subseteq X \times Y and S \subseteq Y \times Z, their composition S \circ R is defined as the set \{(x, z) \mid \exists y \in Y \text{ such that } (x, y) \in R \text{ and } (y, z) \in S\}. This operation is associative, meaning (T \circ S) \circ R = T \circ (S \circ R) for compatible relations R, S, T, but generally not commutative, as S \circ R need not equal R \circ S. For multivalued functions, also known as multifunctions, composition extends the single-valued case by operating on sets of outputs. If g: X \to 2^Y and f: Y \to 2^Z are multivalued functions, where $2^Y denotes the power set of Y, their f \circ g: X \to 2^Z is given by (f \circ g)(x) = \bigcup_{y \in g(x)} f(y). This set-theoretic union captures all possible outputs by applying f to each in the image of g(x), preserving the multivalued nature. In partially ordered sets (posets), composition applies to the order relation itself, which is reflexive, antisymmetric, and transitive. The transitivity axiom ensures that the order relation \leq satisfies \leq \circ \leq \subseteq \leq, meaning repeated does not introduce new pairs beyond the original order. Lattices, as special posets where every pair of elements has a least upper bound (join) and greatest lower bound (meet), inherit this property, allowing relation to model algebraic structures like semilattices through iterative joins or meets. An practical application appears in database systems, where composing queries via relational joins mirrors composition. In , the natural join of two R and S on a common attribute produces a new equivalent to the S \circ R onto the desired attributes, chained queries to combine data across multiple tables. For instance, joining an "Employees" with a "Departments" on department ID composes employee-department mappings to yield a unified of departmental staff.

Applications in Computing

In Programming Languages

In languages, function composition is a core feature that allows developers to combine functions declaratively, often using dedicated operators to create pipelines of transformations. Haskell provides the built-in (.) defined in , with type (.) :: (b -> c) -> (a -> b) -> a -> c, where (f . g) x = f (g x), enabling the creation of new functions by chaining existing ones without explicit nesting. For instance, composing double and square as double . square yields a function that first squares its input and then doubles the result, promoting concise and readable code in pure functional contexts. F#, another functional-first language, supports composition through the forward composition operator >>, which combines functions such that (f >> g) x applies f to x and then g to the result, facilitating the building of complex transformations from simpler components. Complementing this, F# includes the pipe-forward operator |>, which applies a value to a function on its right, as in x |> f |> g, effectively simulating at the value level for enhanced expressiveness in workflows. In imperative languages, function composition is typically achieved through libraries or manual techniques rather than native operators. lacks a standard composition operator but supports it via utility functions in libraries like Ramda or , or through the proposed pipeline operator |>, which would enable syntax like value |> f |> g to pass outputs sequentially, improving readability over nested calls. Python's functools.reduce from the can implement composition by cumulatively applying functions to an initial value, such as using a to chain transformations over a list of functions, though it is more general-purpose for folding operations. Lambda calculus, the foundational model for functional programming, treats function composition implicitly through β-reduction, the primary reduction rule that applies a function by substituting its argument into the body, as in (λx. e₂) e₁ → [e₁/x] e₂, effectively composing abstractions during evaluation. This mechanism underpins computation in languages like , where repeated β-reductions simulate the chaining of functions without explicit composition operators. Across programming paradigms, function composition manifests in through , a form of where methods return the object itself to allow sequential calls, as in obj.method1().method2(), composing operations on the same instance for builder-like patterns. In , libraries like enable composition of observables via operators such as map, filter, and merge, where each operator returns a new observable that processes emissions from the previous one, allowing declarative assembly of asynchronous data flows.

Algorithmic Implementations

In the direct evaluation of a function composition such as (f \circ g)(x) = f(g(x)), the naive approach computes the inner function g(x) first and then applies the outer function f to the result, which is straightforward for shallow compositions but incurs redundant computations if intermediate values from g or prior functions are reused across multiple evaluations or branches. This method scales linearly with the depth of the composition for a single input but becomes inefficient for complex pipelines where inner functions are expensive, as each evaluation restarts from the innermost layer without retaining intermediates. Memoization addresses this by caching the outputs of inner functions, such as storing g(x) in a key-value structure indexed by x, to enable constant-time retrieval for subsequent calls within the same or extended compositions like (f \circ g \circ h)(x). This technique transforms potentially quadratic or worse recomputation costs into linear or sublinear time in practice, especially for compositions with , by avoiding repeated execution of deterministic inner functions. Selective variants further optimize by applying caching only to high-cost subfunctions, preserving efficiency in memory-constrained environments while ensuring correctness for pure functions. In contexts, such as GPU shader pipelines, function composition facilitates the application of transformation sequences—like matrix multiplications for vertex processing—to vast arrays of elements simultaneously, with each GPU independently evaluating the composed on its assigned input. This leverages the architecture of GPUs, where compositions of affine transformations or operations are pipelined across stages, achieving high throughput by distributing the workload without inter-thread dependencies for independent inputs. For instance, in rendering pipelines, sequential compositions of functions are executed in parallel across , reducing through hardware-accelerated networks. The of evaluating compositions varies by structure: linear chains of n constant-time functions can be precomposed into a single O(1)-time evaluator per input, enabling efficient , whereas naive evaluation of tree-like compositions without sharing can lead to time due to duplicative inner computations across branches. Optimized algorithms, such as those using state machine reductions or prefix computations, achieve O(n) total work and O(\log n) depth for composing sequences of n functions, making them suitable for scalable implementations on hardware.

Notation and Typography

Alternative Notations

Point-free notation, also known as tacit programming, is a style in which functions are composed without explicitly referencing their arguments, relying instead on combinators and composition operators to define behavior. This approach originates from combinatory logic and is prominently featured in functional programming languages like Haskell, where the composition operator (.) allows expressions such as f . g to denote the function that applies g first and then f, eliminating the need to name input points. In libraries such as Ramda for JavaScript or the compose recipe in Python's documentation using functools.reduce, point-free definitions are facilitated by utilities like compose(f, g), which returns a new function equivalent to f ∘ g (applying g then f). The arrow notation, common in and , specifies function s and s while implying through chaining. For morphisms f: X → Y and g: Y → Z, the composite is denoted g ∘ f: X → Z, visually aligning the arrows to illustrate the flow from to without additional symbols. This convention underscores the diagrammatic nature of categories, where arrow diagrams directly represent s. Historical variants of composition notation in the include the , used by Dirichlet in works on analytic functions and residues to separate variables from parameters in expressions like f(x; a), though extended in relational contexts to denote sequential application. Other early forms, such as Jordan's juxtaposition AB for substitution sequences (1870) or Lie's TU for transformation products (1888), prefigured modern by representing chained operations on groups or manifolds. These notations evolved amid developments in and , prioritizing clarity in iterative applications over standardized symbols.

Typographical Conventions

In mathematical typography, the symbol for function composition is the ring operator ∘, encoded as U+2218 in , which is specifically noted for representing composite functions. This symbol is rendered with thin spaces on either side when separating function names, as in the expression f \circ g, to ensure clarity and prevent visual crowding in printed or digital formats. Spacing conventions distinguish composition from function application: juxtaposition of function symbols, such as fg to denote f(g), requires no intervening space, reflecting their direct association, whereas the composition operator ∘ is treated as a binary relation or operator, warranting medium or thick mathematical spacing around it in typesetting systems like LaTeX, where the command \circ automatically inserts appropriate gaps via \medmuskip or \thickmuskip. In contrast, multi-letter function names like \sin or \log are often set without spaces in application but spaced around ∘ for composition. Font selection emphasizes distinction between elements: function names and variables are typically set in mathematical italic (sloping) font to indicate they are quantities or identifiers, while the composition operator ∘ itself is rendered in upright (roman) font as a fixed mathematical , aligning with standards for operators to avoid confusion with italicized variables. Mathematical italics require a dedicated —wider than text italics by 5–10% with adjusted —to ensure letters like f or g remain legible and separable when composed. In digital media, rendering challenges arise without full support; environments often fallback to a lowercase 'o' or an asterisk '*' as approximations for ∘, though this can lead to , as 'o' may resemble the rather than the . For accessibility, screen readers handling mathematical content via or similar markup pronounce ∘ as "ring " or "" when supported by extensions like MathCAT, enabling of expressions like f \circ g as structured sequences rather than flat text.

References

  1. [1]
    Functions:Composition - Department of Mathematics at UTSA
    Nov 7, 2021 · In mathematics, function composition is an operation that takes two functions f and g and produces a function h such that h(x) = g(f(x)).
  2. [2]
    Algebra - Combining Functions - Pauls Online Math Notes
    Nov 16, 2022 · The new method of combining functions is called function composition. Here is the definition. Given two functions f(x) f ( x ) and g(x) ...
  3. [3]
    [PDF] Chapter 4 - Basic category theory - MIT OpenCourseWare
    The composition formula ˝ is given by function composition, and for every set X, the identity function idX : X ر X serves as the identity morphism for X P ...
  4. [4]
    Calculus I - Chain Rule - Pauls Online Math Notes
    Nov 16, 2022 · It turns out that it's actually fairly simple to differentiate a function composition using the Chain Rule. There are two forms of the chain rule. Here they ...
  5. [5]
    [PDF] Haskell — Composing Functions - Computer Science
    The built-in operator "." (pronounced “compose”) takes two functions f and g as argument, and returns a new function h as result. The new function h = f . g ...
  6. [6]
    6.4: Composition of Functions
    ### Definition of Function Composition
  7. [7]
    [PDF] Chapter 2 Relations, Functions, Partial Functions
    The main reason for writing function composition as g◦f is that tradition- ally, the result of applying a function, f, to an argument, x, is written f(x). Then, ...
  8. [8]
    [PDF] Chapter 5 Functions: How they have changed through History
    The term function did not appear in a mathematics lexicon published in 1716. Two years later Jean Bernoulli published an article containing his definition of a.Missing: composition | Show results with:composition
  9. [9]
  10. [10]
    2.1 Inverse Functions | Precalculus - Lumen Learning
    ... composition of inverse functions, f−1∘f f − 1 ∘ f equals the identity ... The identity function does, and so does the reciprocal function, because.
  11. [11]
    Introduction to the multivariable chain rule - Math Insight
    The function h(t) is an example of a composition of functions, meaning it is the result of using function g and then using the function f. We often write h ...<|control11|><|separator|>
  12. [12]
    [PDF] Multivariable Vector-Valued Functions - Bard Faculty
    Composition of functions works for multivariable vector-valued functions just as it does for single-variable real-valued functions, with one caveat, which is ...
  13. [13]
    [PDF] 2.5 Chain Rule for Multiple Variables - UCSD Math
    The notation f ◦ g is read as “f composed with g” or “the composition of f with g.” A mountain has altitude z = f(x,y) above point (x,y). Plot a hiking trail ( ...
  14. [14]
    Matrix Multiplication
    The matrix of the composition of two linear transformations is the product of the matrices of the transformations. Example(Composition of rotations) ...
  15. [15]
    multivariable-chain-rule - Stanford AI Lab
    Observe that the order of composition of the derivatives matches the order of composition of the original functions. That is, g ∘ f first applies f then ...
  16. [16]
    [PDF] Functional Composition and Decomposition for Signal Processing
    Specifically, the functional composition framework is exploited in analyzing, design- ing and extending modular filters, separating marginalization computations ...
  17. [17]
    [PDF] Abstract Algebra I - Auburn University
    Nov 15, 2018 · The following theorem says that composition of functions is associative. 1.7.1 Theorem. If f : X → Y , g : Y → Z, and h : Z → W are functions,.
  18. [18]
    [PDF] 1.3b Functions: Inverses and Compositions - Ohio University
    Jan 28, 2021 · Corollary: function composition is associative. That is ℎ ∘ (𝑔 ∘ 𝑓) = (ℎ ∘ 𝑔) ∘ 𝑓. Proof. Suppose that 𝑓,𝑔 are functions 𝑓:𝑆 → 𝑇 ...
  19. [19]
    [PDF] 3.3. Composition of Functions
    Feb 2, 2022 · We show that function composition is associative and illustrate some surprising results concerning functions between infinite sets. Definition. ...
  20. [20]
    Composition of Functions - Department of Mathematics at UTSA
    Jan 20, 2022 · In mathematics, function composition is an operation that takes two functions f and g and produces a function h such that h(x) = g(f(x)).
  21. [21]
    [PDF] Inverse Functions
    Proof. You can check using the definitions of composition and identity functions that (3) is true if and only if both (1) and (2) are true, and then the ...
  22. [22]
    Inverse Functions - Department of Mathematics at UTSA
    Jan 15, 2022 · The inverse of g ∘ f is f −1 ∘ g −1. The inverse of a composition of functions is given by.
  23. [23]
    Section 2.1: Composition of Functions
    The process of combining functions so that the output of one function becomes the input of another is known as a composition of functions.Missing: mathematics | Show results with:mathematics<|control11|><|separator|>
  24. [24]
    [PDF] Section 4.7. Projection Operators
    Apr 22, 2019 · An operator T is idempotent if T2 = T. Theorem 4.7.1. A bounded operator is a projection operator if and only if it is idempotent and self ...
  25. [25]
    [PDF] Continuous Functions - UC Davis Math
    The next theorem states that the composition of continuous functions is continuous. ... Finally, we prove that continuous functions on compact sets are uniformly.
  26. [26]
    [PDF] Differentiable Functions - UC Davis Math
    The chain rule states that the composition of differentiable functions is differen- tiable. The result is quite natural if one thinks in terms of ...
  27. [27]
    iteration - PlanetMath
    Mar 22, 2013 · Let f:X→X f : X → X be a function, X being any set. The n -th iteration of a function is the function which is obtained if f is applied n times ...Missing: mathematics | Show results with:mathematics
  28. [28]
    Fixed Point -- from Wolfram MathWorld
    A fixed point is a point that does not change upon application of a map, system of differential equations, etc.
  29. [29]
    [PDF] Dynamical Systems and Ergodic Theory
    Oct 10, 2018 · Definition 1.1.3. A point x ∈ X is periodic if there exists n ∈ N\{0}, such that fn(x) = x.
  30. [30]
    On composition of formal power series - Gan - Wiley Online Library
    Jan 1, 2002 · This note gives a necessary and sufficient condition for the existence of the composition of some formal power series. By means of the theorems ...
  31. [31]
  32. [32]
    [PDF] Time Evolution in Quantum Mechanics
    First we introduce the time evolution operator and define the Hamiltonian in terms of it. Then we discuss the evolution of state vectors and the Schrödinger ...
  33. [33]
    Full article: Counting monogenic monoids and inverse monoids
    The full transformation monoid is the monoid of all functions from the set { 1 , … , n } to itself (called transformations) and the semigroup operation is ...
  34. [34]
    [PDF] Regular and synchronizing transformation monoids
    Nov 23, 2011 · the symmetric group as Sn.) A transformation monoid is, analogously, a submonoid of the full transformation monoid. T(Ω) on Ω (or Tn on {1, 2 ...
  35. [35]
    [PDF] 1 Monoids and groups
    Perm(U) with composition of functions is a group (the group of permu- tations of U). Note. If U = {1,2,...,n} then Perm(U) is called the symmetric group on n ...
  36. [36]
    Some contributions to the theory of transformation monoids
    Mar 15, 2019 · ... of the full transformation monoid T n containing the set I ( T n ) of all constant mappings on n . In this case, I ( N ) = I ( T n ) ...
  37. [37]
    GAP3 Manual: 78 Transformation Monoids
    There are a function to construct the full transformation monoid of degree n (see FullTransMonoid) and a function to construct the monoid of all partial ...
  38. [38]
    Deformations of the full transformation semigroup | Department of ...
    The Full Transformation Semigroup Tn is the semigroup of all maps from a set of size n to itself. The representation theory of Tn is closely tied to that of ...
  39. [39]
    The countability index of the endomorphism semigroup of a vector ...
    May 30, 2007 · Let V be a vector space over a field F and denote by End V the endomorphism semigroup of V. In the two main results, it is determined precisely ...
  40. [40]
    Green's Relations on a Semigroup of Transformations with ... - MDPI
    Green's relations play a role in semigroup theory, and the aim of this paper is to characterize Green's relations on T ( X , Y , ρ , R ) . As consequences, we ...
  41. [41]
    The origins of combinatorics on words - ScienceDirect.com
    For example, paths in graphs are encoded by words in a natural way, and conversely, the Cayley graph of a group or a semigroup encodes words by paths.
  42. [42]
    2.3 The Chain Rule
    The chain rule in multivariable calculus uses Jacobian matrices and matrix multiplication. If functions are differentiable, the composite function is ...The Chain Rule · Important special cases · Proof of the Chain Rule...
  43. [43]
    None
    ### Summary of Composition Involving Parametric Curves
  44. [44]
    2.3: Transformation Composition and Matrix Multiplication
    Aug 6, 2025 · Composing two transformations means chaining them together: T ∘ U is the transformation that first applies U , then applies T (note the ...
  45. [45]
    Determinants and linear transformations - Math Insight
    It turns out that the determinant of a matrix tells us important geometrical properties of its associated linear transformation.
  46. [46]
    Transformations - LearnOpenGL
    The true power from using matrices for transformations is that we can combine multiple transformations in a single matrix thanks to matrix-matrix multiplication ...Coordinate Systems · Source code · Learnopengl/shader_m.h · Solution
  47. [47]
    Category Theory - Stanford Encyclopedia of Philosophy
    Dec 6, 1996 · Composition of morphisms corresponds to multiplication of monoid elements. That the monoid axioms correspond to the category axioms is easily ...General Definitions, Examples... · Philosophical Significance · Bibliography
  48. [48]
    category in nLab
    Sep 19, 2025 · A category consists of a collection of objects and a collection of morphisms. Every morphism has a source object and a target object.Category Theory · Enriched category · 2-Category · Dagger category
  49. [49]
    horizontal composition in nLab
    Aug 18, 2023 · In a 2-category, horizontal composition is the composition of 2-morphisms along objects, in contrast to vertical composition along 1-morphisms.
  50. [50]
    natural transformation in nLab
    Jun 18, 2025 · A natural transformation is a 2-morphism between two functors, assigning a morphism between objects in the target category for each object in ...
  51. [51]
    relation composition - PlanetMath.org
    Oct 24, 2013 · The first order of business is to define the operation on relations that is variously known as the composition of relations, ...
  52. [52]
    SOME GENERAL PROPERTIES OF MULTI-VALUED FUNCTIONS
    The composition function F = F2 o Fx is defined by F(x) = F^F^x)) for each x e X. Note that in this case F(x) may not be a closed set. Also, if zeZ, then F~\z) ...
  53. [53]
    [PDF] Foundations of Relations and Kleene Algebra - CS@Cornell
    Sep 4, 2006 · Composition of relations: R;S = {(u,v) : uR ∩ Rv 6= ∅}. = {(u,v) ... poset U is an algebraic lattice. In a join-semilattice every ...
  54. [54]
    [PDF] Relational Algebra - Stanford InfoLab
    Products and joins: compositions of relations. ◇Renaming of relations ... Natural join: union of the attributes of the two relations. ◇Renaming: the ...
  55. [55]
    6 Predefined Types and Classes
    ### Summary of Function Composition Operator (.) from Haskell 2010 Report
  56. [56]
    Symbol and Operator Reference - F# | Microsoft Learn
    May 31, 2023 · This article includes tables describing the symbols and operators that are used in F# and provides a brief description of each.Comment, compiler directive... · String and identifier symbols
  57. [57]
    ES pipe operator (2021)
    ### Summary of the Proposed Pipeline Operator in JavaScript and Its Relation to Function Composition
  58. [58]
    functools — Higher-order functions and operations on callable ...
    The functools module is for higher-order functions: functions that act on or return other functions. In general, any callable object can be treated as a ...
  59. [59]
    [PDF] Lecture Notes on The Lambda Calculus
    Aug 31, 2021 · We call this β- reduction and it is the engine of computation in the λ-calculus. The simplest functions are the identity function and the ...
  60. [60]
    Fluent Interface - Martin Fowler
    Dec 20, 2005 · A certain style of interface which we decided to name a fluent interface. It's not a common style, but one we think should be better known.
  61. [61]
    ReactiveX - Operators
    ### Summary: How Operators in ReactiveX Allow Composition of Observables
  62. [62]
    Improving efficiency of recursive functions (article) - Khan Academy
    We can use a technique called memoization to save the computer time when making identical function calls. · A memoization of the factorial function could look ...
  63. [63]
    [PDF] 5.1 Efficient Function Composition
    Jan 29, 2009 · This procedure can be used to construct a parallel algorithm with linear work and log(n) depth which can figure out the state after any sequence ...
  64. [64]
    [PDF] Synthesizing Efficient Memoization Algorithms - Yingfei Xiong
    In this paper, we propose an automated approach to finding correct and efficient memoization algorithms from a given declarative specification.
  65. [65]
    [PDF] Selective Memoization - CMU School of Computer Science
    A critical issue for efficient memoization is the implementation of memo tables along with lookup and update operations on them. In our framework we support ...
  66. [66]
    Examples of "inner products" of parallel morphisms in a dagger ...
    Aug 10, 2011 · (You might remember this backslash notation from a recent answer of mine to a question of James Propp.) This S∖R is a "right Kan lift" in ...<|separator|>
  67. [67]
    composition in nLab
    Jun 1, 2025 · In a plain category ; f · x · y f\colon x \to y and ; g · y · z g\colon y \to z in a category and produces a morphism ; g · x · z g \circ f\colon x \to z ...
  68. [68]
    Category: The Essence of Composition
    Nov 4, 2014 · Arrows can be composed, and the composition is associative. Every object has an identity arrow that serves as a unit under composition.
  69. [69]
    None
    Belowis a merged summary of the historical notations for function composition from the 19th century, based on the provided segments from *A History of Mathematical Notations Vol. II (1928)*. To retain all information in a dense and organized manner, I will use a combination of narrative text and a table in CSV format for key details. The response will cover all mentioned mathematicians, notations, and contexts, focusing on function composition where applicable, while also noting related mathematical developments.
  70. [70]
    Mathematical Operators - Unicode
    Asterisk Operator. •, may be used to represent the telephony asterisk seen on keypads. →, 002A * asterisk. 2218, ∘, Ring Operator. = composite function. = APL ...
  71. [71]
    Spacing in math mode - Overleaf, Online LaTeX Editor
    The example below contains a complete list of spaces inserted using various commands and demonstrates their effect on the typeset math.
  72. [72]
    [PDF] Fonts for Mathematics
    It is preferable to use a special, slightly wider Math Italic. é Better separation of text and math. é Kerning of Math Italic is different. Each letter should ...
  73. [73]
    [PDF] On the use of italic and roman fonts for symbols in scientific text
    The general rules concerning the use of an italic (sloping) font or a roman (upright) font are presented in the IUPAC Green Book [1] on p.5 and 6, and also ...
  74. [74]
    Function composition - Rosetta Code
    Oct 16, 2025 · The function composition operator is ∘, U+2218 RING OPERATOR (with a "Texas" version o for the Unicode challenged). Here we compose a ...
  75. [75]
    UTR #25: UNICODE SUPPORT FOR MATHEMATICS
    Oct 2, 2025 · For example, U+2218 ∘ RING OPERATOR may be the equivalent of white small circle or composite function or APL jot. The Unicode Standard does ...
  76. [76]
    Making Math Accessible - TPGi — a Vispero company
    Feb 28, 2024 · A goal of MathCAT is to be an easy to use library for screen readers and other assistive technology to use to produce high quality speech and/or ...