Function
A function is a rule that assigns each input exactly one output.
- Let and be nonempty sets. A function from to , denoted by , is an assignment of exactly one element of to each element of .
- We write if is the unique element of assigned by the function to the element of .
- Functions are sometimes also called mappings or transformations.
Terminologies
Image
The image is the input of a function.
If , we say that is the image of and is the preimage of .
Domain
The domain is the set of all inputs. The codomain is the set of all allowable outputs.
If is a function from to , we say that is the domain of and is the co-domain of .
Range
The domain is the set of all inputs that have outputs.
The range of is the set of all images of the elements of .
Uses
- They are used in the definition of sequences and strings.
- They are used to represent how long it takes a computer to solve problems of a given size.
- Recursive functions are used throughout computer science.
Properties
- Two functions are equal when they have the same domain, same codomain, and same mapping of elements.
- A different function is obtained when either the domain or the codomain of a function is changed.
- A different function is also obtained if the mapping of elements is changed.
Examples
Example
defined by . The domain and codomain are both the set of integers. However, the range is only the set of integer multiples of 3.
Example
Example
defined by . The reason this is not a function is because not every input has an output. Where does send ? The rule says that , but is not an element of the codomain.