# Function

## Introduction

A function was originally the idealization of how a varying quantity depends on another quantity. In many cases, we assign a particular element of a second set( which might be the same as the first) to each element of a set.

For Example, suppose each student in a class is assigned a letter grade from set S= { A, B, C, D, F} and suppose the grades are A for Alina, B for Ali, C for Robert , D for Noman, F for Amanda . This assignment of grades will be shown as follows

An example of a function is above assignment. In mathematics and computer science, the concept of a function is extremely important.In the definition of such discrete structures as sequences and strings, for example, discrete math functions are utilized.It also shows how long a computer takes to solve problems of a particular size. Many computer programs and subroutines have been designed to calculate function values.Recursive functions, which are self- defined functions, are used in computer science.

## Function Definition

A function f from a set X to a set Y is a relationship between elements of X and elements of Y such that each element of X is related to a unique element of Y, and is denoted  f : X →Y.

The set X is called the domain of f and Y is called the co-domain of f.

In many different ways, functions are specified. Sometimes we declare the tasks explicitly. We often provide a formula for defining a function, such as f(x)= x+ 1. We used another time to specify a function using a computer program.

## ARROW DIAGRAM OF A FUNCTION

The definition of one function involves the following two properties in the arrow diagram for a function f:

1. An arrow comes out of every X element
2. No two X elements have two arrows from which two distinct Y elements appear.

Example:

Let X = {a,b,c} and Y={1,2,3,4}.

Define a function f from X to Y by the arrow diagram

The above diagram easily fulfills the two requirements of the function, hence a function graph.

Note that:

f(a) = 2

f(b) = 4

f(c) = 2

## Functions and Non-Functions

Which of the arrow diagram describes functions from X={a, b, c} to Y={d, a, f, g}

The relation given in the diagram (a) is Not a function because there is no arrow coming out of 5∈X to any element of Y.

The relation in the diagram (b) is Not a function, because there are two arrows coming out of 4∈X. i.e.,4∈X is not related to a unique element of Y.

## Range of function

When “range” is used to mean “codomain“, the image of a function f is already implicitly defined. It is (by definition of image) the subset of the “range” which equals {y | there exists an x in the domain of f such that y = f(x)}.

When “range” is used to mean “image“, the range of a function f is by definition {y | there exists an x in the domain of f such that y = f(x)}. In this case, the co-domain of f must not be specified, because any co-domain which contains this image as a subset will work. [Wikipedia]

In both cases, image f ⊆ range f ⊆ co-domain f, with at least one of the containment being equality.

Note:

1. The function f range is always a subset of the co-domain of f.
2. The range of f: X→Y is also called the image of X under f.
3. When y = f(x), then x is called the pre-image of y.
4. The set of all elements of X, that are related to some y ∈Y   is called the inverse image of y.