Example:Partial function

From CS2800 wiki
Revision as of 17:24, 17 February 2018 by {{GENDER:Mdg39|[math]'"2}} [/math]'"7
(<math>1) </math>2 | <math>3 (</math>4) | <math>5 (</math>6)

The function [math]f : \href{/cs2800/wiki/index.php/Enumerated_set}{\{1,2,3\}} \href{/cs2800/wiki/index.php/%E2%86%92}{→} \href{/cs2800/wiki/index.php/Enumerated_set}{\{a,b\}} [/math] given by the following diagram:


is not well-defined (i.e. is not a function). A function must give an output for every input; but this function does not give an output for 2.

Although we would not call this a function, it is an example of a partial function.

A partial function is like a function, except that it does not need to give an output for every input. However, the outputs it does give must be unambiguous. One way to formalize this is by defining a partial function as a function from a restricted domain:

Definition: Partial function
A partial function [math]f : A \href{/cs2800/wiki/index.php/%E2%86%9B}{↛} B [/math] is a subset [math]S⊆A [/math] (called the support of [math]f [/math]), along with a function [math]\tilde{f}:S \href{/cs2800/wiki/index.php/%E2%86%92}{→}B [/math] We say that [math]f(x)=y [/math] if [math]\tilde{f}(x) = y [/math] and [math]f(x) [/math] is undefined if [math]x \href{/cs2800/wiki/index.php/%5Cnotin}{\notin} S [/math].
Definition: Total
A partial function [math]f [/math] is total if the support is equal to the domain, i.e. if [math]f [/math] is a function.

Note that, somewhat confusingly, not all partial functions are functions. However, we do consider a (total) function to be a partial function. We use this terminology because it is standard in mathematics and because it simplifies proofs (so that we don't have to say "a partial or total function" in places where the same argument works for both).

To summarize,


is a partial function, but not a function (because it is not total), while


is a partial function, a function and a total function (also an injection, a surjection, a bijection, and a relation).