In algebra, a relation is any association between the elements of one set to another i.e. domain and co-domain. Usually relation is denoted by R and it is a subset of the Cartesian product of two given sets. Elements of a relation is defined as the ordered pairs like (a,b).
The most important type of relation is function. A function is a relation in which every element from domain is mapped with exactly one element to co-domain. The elements of domain and co-domain are said to be independent and dependent variables respectively. Generally, function denoted by f.

Now we will discuss moreover about relations, functions, dependent and independent variables.

## Dependent and Independent Variables

From an applications point of view, an independent variable is a variable, which is selected by the experimenter to determine its relationship to an observed phenomenon. It can be manipulated by a person(researcher). The dependent variable is the outcome of experiment.
The most common independent value, is time.
In study or in an experiment, where one variable causes the other, the independent variable is the cause and dependent variable is the effect.

In mathematical language a dependent variable is a function of the independent variable(s).
For example, consider the following equation: y = 7x + 3

Here 'x' and 'y' are variables. A change in the value of variable 'x', will change the value of 'y'.
So 'y' is dependent on 'x' or 'y' is a function of 'x'. In mathematical language, this is written as:
y = f(x) = 7x + 3

So if we take certain random values of variable 'x' we find the values of dependent variable 'y' captured in table below. Here every value of y depends on value of x, so we can say x is independent variable and y is dependent variable.

## Relations

A relation is any association between elements of one set, called the set of inputs, and another set, called the set of outputs and can be written as ordered pairs. There is a difference between the range and co-domain. Range of a relation and means the set of all possible outputs - values that the relation does not actually use.

For example, if domain is a set of Fruits = {apples, grapes, bananas} and the co-domain is a set of Colors = {red, green, yellow} then the colors of these fruits form a relation. We might say that apples are related to red, while grapes are related to green only and bananas to yellow only.
Another way of looking at this is to say that a relation is a subset of ordered pairs drawn from the set of all possible ordered pairs of elements of two other sets, which we normally refer to as the Cartesian product of those sets.
Using the example above, we can write the relation in set notation: {(apples, red),
(grapes, green), (bananas, yellow)}.
In general, a relation is any subset of the Cartesian product of its domain and co-domain. If A and B are two sets, then a relation R from A to B is a sub set of A × B. So R is a relation, if R $\subseteq$ { (x , y) I x $\in$ X and y $\in$ Y} for domain A and co-domain B.
Example 1:

Consider the sets A = { a, b, c} and B = { 1, 2, 3},
then the Cartesian product of A and B is A x B = { (a,1), (b,2), (c,3)}.
If we take B x A = {(1,a),(2,b), (3,c)}.
It is clear that A x B $\neq$ B x A , i.e. formation of Cartesian product is not commutative.

Example 2:

Consider a set A = { a,b,c,e,f,i}.
Now consider the relation on
B = { (x,y) $\in$ A x A I where x is vowel and y is not a vowel}

Then elements of B are:
{(a,b), (a,c), (a,f), (e,b), (e,c), (e,f), (i,b), (i,c), (i,f)}

We can also write these elements as
aRb, aRc, aRf, eRb, eRc, eRf, iRb, iRc, iRf.

## Function Definition

A function is a mapping between two sets and it is a binary relation from one set to another set.
So if f : X $\rightarrow$ Y such that x$\in$ X there exists one and only one y $\in$ Y, then we can say that x f y or f is a function from X to Y. Where y is known as the image of x and denoted by f(x), x is said to be the pre-image of y.
So mathematically,
f : X $\rightarrow$ Y such that y = f(x).

If E is a set, then we can define:
f (E) = { f(x) I x $\in$ E},
above set is said to be the range of f and E is called domain of f. Set E represent the set of all values that f takes. Range of any function is a subset of co-domain of f.

Example 1:
Calculate the following function:
h : R $\rightarrow$ R, where y = h(x) = x2 + 3x -3
At the values x = -3, -1, 0,2, 3.
Solution:
Given that h : R $\rightarrow$ R, then
h(-3) = (-3)2 + 3(-3) -3 = 9 - 9 -3 = -3
h(-1) = (-1)2 + 3(-1) -3 = 1 -3 -3 = -5
h(0) = (0)2 + 3(0) -3 = -3
h(2) = (2)2 + 3(2) -3 = 2 + 6 -3 = 5
h(3) = (3)2 + 3(3) -3 = 9 + 9 - 3 =15
These values can be arrange as ordered pairs (-3,-3), (-1,-5), (0,-3), (2,5), (3,15)

Example 2:
Find the domain and range for the following function:
f : R $\rightarrow$ R and y = f(x) = 4x -2.
It is clear that x is a real number then 4x -2 is also a real number.
Hence domain of f is the set of all real number i.e. Dom(f) = R.

For range, we solve the given equation for the elements of its co-domain R that have its pre-image under the function.
We have y = f(x) = 4x - 2
x = $\frac{y + 2}{4}$
So every real number y has its pre-image, it means f(R) = R.

## How to Determine Whether a Relation is a Function

Now at this point, we come to know that a function is a special type of a relation. At a first chance, function looks like a relation. It is also a set of ordered pairs like (a,b) type and as similar to relation, function has its domain and co-domain.

But we can easily differentiate a function and relation with the help of each x values or their input values. We know that in function every x value has one and only one y value and if any one element is missing to map from domain to co-domain then its not a function.
In short, "a relation is a function, in which no two ordered pairs have the same first coordinate or element but two ordered pairs can have the same second element". All functions are relation but all relation are not function.
Example:
Identifying each given relations is a function or not and provided the reasons.
(a) {(1,2), (2,4), (5,9), (4,3)}
(b) {(0,1), (1,1), (2,3), (4,2)}
(c) {(1,2), (2,3), (3,4), (4,5)}
(d) {(1,1), (2,1), (3,5)}

Solution:
(a) {(1,2), (2,4), (5,9), (4,3)} is a function because no ordered pairs have the same first element.

(b) {(0,1), (1,1), (1,3), (4,2)} is not a function since second and third ordered pairs have the same first coordinate 1.

(c) {(1,2), (2,3), (3,4), (4,5)} is a function since none ordered pairs have the same first element.

(d) {(1,1), (2,1), (3,5)} is a function since none ordered pairs have the same
first element. Here ordered pairs first (1,1) and second (2,1) have the same
second element 1, but it is a function because its important that these ordered
pairs have different first elements i.e. 1 and 2.

## Graphing Relations and Functions

Sometimes we use the graph of the equation for determining if the given equation is a relation or function. We can draw a graph in cartesian coordinate system, polar coordinate system, pedal coordinate system etc. But usually we use the cartesian coordinate system for relation and function.

In cartesian coordinate system we have two lines vertical line and horizontal line. Vertical line is known as y-axis and horizontal line is known as x-axis respectively. The quadrants have the numbers I, II, III and IV in anticlockwise. And a point in cartesian coordinate system is represented by an ordered pair (x,y). "If we draw a graph of a relation it means we usually represented the ordered pairs as the points in cartesian coordinate system."

Example:
Suppose we have a relation R = {(1,2), (2,3), (3,4), (0,1)}
We know the relation is a collection of ordered pairs. If we plotted it in a graph then this is said to be the graph of the relation R. Creating the graph of function: If we draw a graph for an equation y = x3, this type of information raises some difficulties like,
(a) From the instruction, we don't have enough information about the direction i.e. what
does the instruction mean.
(b) We have incorrect information or instruction, because we draw the graph of a relation or
function not an equation. Since graph is a different way to express a function or relation
that presents in an ordered pairs.

If we have collection of all ordered pairs of function f, then we can easily drawn the graph of that function. So
graph of f = { a, f(a) : a belongs to the domain of f}

The graph of function f is the collection of all ordered pairs (x,y) where x $\in$ X and
y $\in$ Y.
Example:
If f : R $\rightarrow$ R and defined as y = f(x) = $\frac{x^2}{2}$.
Since x $\in$ R, so we have some ordered pairs of this, like: And if we plot the graph of the given equation with the help of above table, then Above graph satisfies the functional relationship, hence the given equation
y = f(x) = $\frac{x^2}{2}$ is a function.