In mathematics, a partial function from X to Y (written as f: X ↛ Y) is a function f: X ′ → Y, for some subset X ′ of X. It generalizes the concept of a function f: X → Y by not forcing f to map every element of X to an element of Y (only some subset X ′ of X). If X ′ = X, then f is called a total function and is equivalent to a function. Partial functions are often used when the exact domain, X, is not known (e.g. many functions in computability theory).
Specifically, we will say that for any x ∈ X, either:
For example, we can consider the square root function restricted to the integers
Thus g(n) is only defined for n that are perfect squares (i.e., 0, 1, 4, 9, 16, ...). So, g(25) = 5, but g(26) is undefined.
There are two distinct meanings in current mathematical usage for the notion of the domain of a partial function. Most mathematicians, including recursion theorists, use the term "domain of f" for the set of all values x such that f(x) is defined (X' above). But some, particularly category theorists, consider the domain of a partial function f:X → Y to be X, and refer to X' as the domain of definition. Similarly, the term range can refer to either the codomain or the image of a function.
Occasionally, a partial function with domain X and codomain Y is written as f: X ⇸ Y, using an arrow with vertical stroke.
A partial function is said to be injective or surjective when the total function given by the restriction of the partial function to its domain of definition is. A partial function may be both injective and surjective.