# Introduction to real functions

Real functions are the most important type of a mapping. After introducing this notion we look at inverse functions and functions defined by cases.

Definition.
By a real function of real variable we mean any mapping from some subset of the set of real numbers to the set of real numbers.

Note that people usually say just real functions and it is understood that we mean real functions of real variable. Other kinds of real functions (like real functions of complex variable) are always specified in full.

To a matematician, this definition of real functions is entirely satisfactory, since all properties known for mappings readily transfer to functions. However, for a practical user of mathematics this is less suitable, since one can happily and efficiently use real functions without even knowing about the existence of general mappings, and one can also do with less precision. We will therefore try to explain what a real function is without referring to mappings. This is best done by means of an example. We will use one inspired by physics, since indeed physics has been the inspiration for introducing functions in the first place. We will also use this example to review notions of domain, 1-1, onto, and inverse, so we definitely recommend that you look at it. We prefer to offer it as a separate page, since it is quite long and also since we will refer to it in other parts of Math Tutor.

Now we will briefly cover the basic notions.

A real function is a prescription which assignes values to arguments. The notation y = f (x) means that to the value x of the argument, the function f assigns the value y. Sometimes we also use the notation f : x ↦ y, in words, the function f sends x to y. The most usual way of specifying this assignment is by some formula, that is, the function value y can be obtained by substituting x to a specific formula that identifies the given function. For instance, the function f (x) = 2x + 3 would send the argument x = −1 to f (−1) = 2⋅(−1) + 3 = 1. A very special case is the constant function, for instance the definition g(x) = 7.3 sends every argument x to the value 7.3; this is sometimes confusing for beginners, so take this as a warning that one can "substitute" x into 7.3, and the outcome is 7.3 (like this: g(5) = 7.3).

There is an alternative way to express the idea hat we substitute some concrete number into a function. It uses a slightly lowered vertical bar and goes like this:

This notation is especially handy if the function is not ripe for substituting yet and we want to make some adjustments first. For example,

The best way to visualize functions is by means of the graph, where we mark in the two-dimensional plane (xy) all couples (xf (x)). We pointed out one such particular couple in the picture.

Note that if a function is given by a formula, we may be also interested in its algebraic make-up, which is another way to look at it, independent of the geometric point of view of the graph. For detail see the note on order of evaluation.

The domain of the function is sometimes given when the function is defined. More often, the real function is just given as a prescription, a formula, in which case for domain we take the set of all numbers x that can be substituted into the function, that is, for which the formula defining the function makes sense. It is usually denoted by Df ), Df , or dom( f ), here we will use the first notation. We can write

Df ) = {x∈ℝ;  f (x) makes sense}.

Typically, the domain would be a union of intervals.

The range of the function is the set of all values that can be obtained by substituting arguments from the domain. It is usually denoted by Rf ), Rf , or ran( f ), here we will use the first notation. We can write

Rf ) = { f (x); xDf )}.

Sometimes the given function is considered only on a subset of the domain. We then say that the function was restricted to this subset, the new function is called the restriction. If M is a subset of the domain Df ) of a function f, then the restriction of f to the set M is denoted f |M.

The restricted function has a different domain and might have a different range (although this is not necessary, sometimes a function can cover all its values on that subset to which we restrict it and only repeats them in the parts that were ignored).

The properties of functions depend a lot on their domains, so one in fact always has to think of a function and its domain as a pair. This is also reflected in the following

Definition.
We say that two functions, f and g, are equal, denoted f = g, if they have the same domain D and for all x from D we have f (x) = g(x).

Consider the following example. This equality is obviously true:

Now we will define two functions.

Although algebraically these two formulas are the same, the two functions are not, we cannot write f = g, because their domains are not the same:

Sometimes we want to disregard values of f outside a specific set M, but we still want to be able to work on its whole domain. Then the notion of restriction does not help, instead we can "kill" the values of f outside M like this:

This approach has several advantages, one is that the function g can be expressed algebraically, see the section on characteristic functions in Theory - Elementary functions.

There is an alternative way to visualize functions. It carries less actual information about the given function, but it is sometimes helpful in emphasizing the function as a procedure for sending points from one set to points in another set. A real function actually sends points from one copy of reals to another (different) copy of reals, the difference is emphasized by different letters for elements of the two sets.

Sometimes we may even indicate how some points are sent, for instance the function  f (x) = 2x + 3 can be shown as follows:

1-1 functions.
A function is said to be 1-1 if it does not happen that two different arguments would lead to the same value. That is, for a 1-1 function f it cannot happen that for distinct x1,x2 from the domain one would have f (x1) = f (x2). In a graph, a function is 1-1 if it does not happen that some horizontal line intersects the graph of the function at more than one place. As you can see in the picture, the original function f is not 1-1, but its restriction g is 1-1.

In practice it is easier to work with a different condition, formally the counterpositive of the above conditon: If after substituting two points we get the same value, then it must have been the same point.

Definition.
We say that a function f is 1-1 (or injective, or an injection) if for all x1,x2 from its domain the following implication is true: If f (x1) = f (x2), then x1 = x2.

If we were also given a target set B with the function f, we can ask whether f is onto (or surjective, or a surjection), that is, whether the target set is equal to the range, B = Rf ). However, this almost never happens with real functions. Usually we are not given the target set, in which case we take the range for the target set and the function is automatically onto, we do not investigate this property.

A function is bijective (a bijection) if it is 1-1 and onto. For real functions this means that we only worry about being 1-1.

## Inverse function

By an inverse function of a function f (or its inverse for short) we mean another function g which satisfies the condition gf (x)) = x for all x from Df ) and f (gy)) = y for all y from Rf ) — if you are uneasy about what these formulas mean, check out composition in the next section on operations. The first equality means that when the function f sends the argument x to some point f (x), then applying the inverse function g to this number f (x) "undoes" this "sending", returns you back to where you started. The second equality says that also f undoes the effect of g. One can prove that if the first equality is true (for all x from the domain of f ), then the second equality automatically follows.

If such an inverse function exists, we denote it f−1. Actually, most textbooks prefer the highly unsuitable notation f −1, see the note in the above Example.

There is a well-known theorem which states that an inverse exists exactly when the given function is a bijection. For real functions we however have a special form:

Theorem.
Assume that f is a real function with domain Df ) and range Rf ). It has an inverse if an only if it is 1-1. Then the inverse is unique and satisfies

Df−1) = Rf ),     Rf−1) = Df ).

The graph of an inverse function can be obtained by flipping the graph of f around the main diagonal. This, by the way, shows the importance of being 1-1 for the existence of an inverse. In the following picture we first show an example of a function that has an inverse. The second picture shows a function that is not 1-1 (we get to the indicated value y from two different values of argument). You can see that when we attempt to flip around its graph, we obtain something that is definitely not a graph of a function, since a function cannot have two values for one argument.

We will return to the inverse in the next section, Operations with real functions, namely when talking about composition.

Example. Consider the function

f (x) = 4 − (1 − x)2.

First we need to look at the domain. What numbers x can be substituted into this formula? We know that any real number can be squared, so the answer is: All real numbers. Therefore Df ) = ℝ.

Range is usually much less important, it is also often difficult to determine, so in most cases we do not bother. However, here it is quite simple, so we try it. What values can be obtained using the formula for f ? We know from experience that squares are always positive or at least zero, so the formula 4 − (1 − x)2 cannot yield a number larger than 4. This shows that the range should be a subset of the interval (−∞,4]. Could it actually be equal to this interval? In other words, can we get an arbitrary number from this interval using the given formula? This translates to the following question: Can we get any non-negative number using (1 − x)2? Since the answer is positive, we conclude that the range is Rf ) = (−∞,4].

What about being 1-1 and having an inverse? We know that these two questions are equivalent. To solve the first one, we try to prove the implication for the definition. We assume that f (x1) = f (x2) and see where it takes us:

4 − (1 − x1)2 = 4 − (1 − x2)2,
(1 − x1)2 = (1 − x2)2,

We know that this equation has two possible solutions. One is 1 − x1 = 1 − x2, that is, x1 = x2, which is the trivial solution we always get (it says that to get to the same place, one can start twice from the same place, which is obviously always true). But there is also another solution, (1 − x1) = −(1 − x2), that is, x2 = 2 − x1. This is more interesting, because it shows that there might be two different numbers going to the same place. We will try it with some concrete numbers. For instance, choosing x1 = 0 we get x2 = 2. Check:

f (x1) = f (0) = 4 − (1 − 0)2 = 3,     f (x2) = f (2) = 4 − (1 − 2)2 = 3.

We confirmed that two different arguments, 0 and 2, are assigned the same value, namely 3. Therefore the function f is not 1-1 and does not have an inverse.

We can also try to find the inverse function and see if we succeed. For the inverse to exist, we should be able to reverse the assignment x ↦ y, that is, given y from the range of f, we should be able to solve the equation f (x) = y uniquely for x. We try it:

f (x) = y,      4 − (1 − x)2 = y,     (1 − x)2 = 4 − y.

We know that this equation has two distinct solutions, namely we can have x equal to 1 minus root of 4 − y or 1 plus root of 4 − y, which again shows that there is no inverse.

Drawing a graph properly is covered later in Graphing functions in Derivative - Theory, so to get at least some idea of the graph of our f, we start by getting some points on it, that is, by calculating the values of f at many values of x. Of course, the more the better, but for simplicity we will try just some here:

 x: f (x):
 −2 −5
 −1 0
 -0.5 1.75
 0 3
 0.25 3.4375
 0.5 3.75
 0.75 3.9375
 1 4
 1.25 3.9375
 1.5 3.75
 1.75 3.4375
 2 3
 2.5 1.75
 3 0
 4 −5

We put these values in the graph:

They suggest the general shape. In fact, the exact shape is a parabola turned down, like this:

We see right away that this function is definitely not 1-1, since apart from the vertex (1,4), all levels on it can be reached from two different values of argument, in other words, it fails the necessary condition about as badly as possible.

We can also see from the picture that if we restrict this function to just one branch of the parabola (or even just a part of it), it becomes 1-1. For instance, we can consider the function g obtained by restricting f to the open interval (−∞,0).

This function is now 1-1 and has an inverse, we confirm this by succesfully finding it. We need to solve the equation g(x) = y, which, as we have seen, leads to the equation (1 − x)2 = 4 − y. But now the only possible x's are from the interval (−∞,0), which means that (1 − x) should be at least 1, in particular positive. Therefore, when taking roots in the equation, we have to put (1 − x) equal to the positive root of 4 − y. Consequently we obtain

Thus we found the inverse function, incidentally proving that it exists and that the function g is 1-1. The inverse function has domain D(g−1) = (−∞,3), range R(g−1) = (−∞,0) and graph

Note how it came naturally that the inverse function has y as its variable. Since in most cases we prefer x as variable, people often, when finding the inverse function, switch variables and eventually write g−1(x) = 1 - root of (4 − x). While formally this is not entirely wrong—we may use any letter for the free variable when working with an individual function, it is not quite correct either. The reason is that g−1 does not exist by itself, but in the context of g. That function is given, it sends numbers from the copy of reals denoted by x to another copy of reals denoted using the letter y, while by definition g−1y) sends numbers the other way around. Therefore g−1y) has to use y as its variable, otherwise we are mixing different worlds, formally g−1 cannot accept numbers from the world of x as its domain is somewhere else. This distinction becomes all the more important in applications when the variables have some physical meaning, switching them would lead to nonsense.

Note that if we chose another restriction on the left half of the parabola, for instance to (−∞,1), (−∞,1], or perhaps to (−∞,−13], we would get different inverse functions. They would be given by the same formula, but their domains and ranges would differ. If we restricted f to some part of the right branch, for instance to [1,∞), we would now even get a different formula for the inverse. And if we restricted f to, say, the interval (0,2), then the restriction would not be 1-1 and it would have no inverse.

Remark: When talking about the inverse g−1, we said that we can change the letter denoting the variable. What does such a change mean? If we change all the appearances of one letter into another letter, from mathematical point of view nothing changes. In fact we can use any letter we wish, as long as we do it consistently and do not use the same letter for some other thing in the same situation. In particular, changing a letter in the description of a function does not change it; the object is still the same. For instance, the function f (w) = 4 − (1 − w)2 is the same function as the one in the Example above. We would also change the label at the horizontal axis in the graph and then everything that we did in the example with x could be done with w, yielding the same answers. In other words, this new function is exactly the same, and for instance f (k) = 4 − (1 − k)2 is still the same function, what is important is not the letter we use for the variable, but the expression defining the function. While it is good to stick to letters that are traditional for the argument (that is, for the variable), it is sometimes to our advantage to use a different letter, for instance because it may better fit with some more complicated setup.

One has to be a bit careful if there are more letters in play, say a function may have its definition dependent on some parameter p. For instance, the formula xp defines, for a fixed value of p, a function - namely a power, with x as the variable. When more letters are in place, one has to be careful not to mix variables and parameters, it is also necessary to be a bit more careful when deciding on changing the name of the variable so that there is no mix-up.

## Functions defined by cases

Some functions are not given by just one formula, but by several, some arguments are being substituted into one formula, others into a different one. We say that such a function is defined "by cases", or that it is "piecewise-defined", or that it is a "split function" (which we prefer here), and typical example would be this:

How does this work? Arguments for which we know f can be taken from the closed interval [1,2] or from the open interval (2.5,4), so the domain of this function is

Df ) = [1,2] ∪ (2.5,4).

When we want to substitute some x from the domain, we check into which of the alternatives it falls and then use the appropriate formula. For instance, x = 1.5 belongs to the first named interval, so we should use the first formula: f (1.5) = 1.52 = 2.25, while 3 belongs to the second interval and therefore f (3) = 4 − 3 = 1. When we try to visualize the graph of f by calculating many points, we should get the correct feeling that the graph of f looks like the piece of the graph of x2 corresponding to the interval [1,2] and the piece of the graph of 4 − x corresponding to the interval (2.5,4) put together:

And that is exactly how functions defined by cases are investigated. Each case is checked separately and the graphs and answers are then put together. One can also have more cases with more interesting conditions, for instance the function

It has domain

D(g) = {−1} ∪ (0,3) ∪ {4} ∪ [5,∞)

and the graph

Some values: g(−1) = (−1)6 = 1 (the last alternative), g(1) = 1 (the third alternative), g(2.3) = 1 (the third alternative), g(4) = 3 (the second alternative), g(6) = 6 − 4 = 2 (the first alternative), g(7) = 7 − 4 = 3 (the first alternative).

This idea of putting together pieces of functions is used not only with functions defined by cases, but also with functions that are defined by one formula, but their domains split into several parts. For instance, the function h(x) = 1/x has domain D(h) = (−∞,0) ∪ (0,∞) since one can put all numbers but zero into this formula. Thus one can investigate separately the parts of the graph on the right and on the left and then put the information together.

Sometimes a function is given by one formula, but definition by cases is hidden in it, which is above all the case of the absolute value.

For more information on working with split functions see Split functions in Derivative - Theory - Graphing functions.