A relation is a mathematical object that takes some sort of input and returns some sort of output. The domain is what we call the input and the range is what we call the output. Some relations:

Relation S takes in a letter and puts out the next letter in the alphabet. For example S(q) = r. The domain here is letters other than z, because there is no next alphabetical letter after z, therefore the function is undefined for z. The range is all letters but a, and the reason a is included is because no alphabetical number put into the function can give us a because there is no letter before a.

Relation W takes in a number and puts out 1. For example W(17000) = 1. The domain is all numbers. The range is simply 1 because for every number put into W we always get 1.

Relation Q takes in a number and outputs a number that is equal to the original number when squared. For example, Q(4) = 2 or -2, because both of those squared become 4. The domain becomes all numbers for which there is a square of (which is only positive numbers unless we're working with a set of numbers that allows for complex numbers), and the range is either all reals or complex numbers (depending on what we want to go with -- without complex numbers we can only make positive squares).

Generally speaking when you're working with a function that is complicated you'll want to specify sets the function is working between. The domain and range will then be subsets of the sets the function moves between. You'll notice I didn't really do that above, which made describing the domain and range of Q very problematic. Q itself seems rather strange for another reason, which I will go into here:

You'll notice that in Q there are 2 values which can be chosen, whereas all of the others results in only 1 answer for each input. This iswhat makes S and W a function where Q is only a relation. Formally the definition of a function is:

f is a function if and only if for every f(x) there exists a unique y such that f(x)=y

This means essentially that you can't put in the same number twice and get a different answer. When you're looking at a graph of a function, you can do a visual test of whether or not the graph represents a function or a relation called the vertical line test. To do this, you simply hold a ruler to the graph vertically and then move the ruler from left to right (or right to left) over the graph. If at any point the ruler touches the graph in two places, then it is not a function (because that would require there to be a 2 y's for one x).

Lets return to Q, the relation that isn't a function. By applying the rigid definition we can see that because Q(4) = 2 or -2, it isn't a function (because we have 2 answers for the input of 4). But what does this particular function actually appear to be when graphed? Well, our value y squared (2 and -2) has to be equal to x, giving us the equation y*y = x, or two functional halves y = sqrt(x) and y = -sqrt(x). So it's two graphs that are are mirrored by the x axis, meaning no matter where you touch the graph that it is defined, you're gonna hit two points. So it fails the vertical line test.