Functions

1. Function Notation and Terminology

A function (or map) is a rule or correspondence that associates each element of a set X called the domain with a unique element of another set Y called the codomain. We typically give the rule a name such as a letter like f or g (or any letter of your choice) or a name agreed upon by convention like sine or log or square root. The term "unique" is critical in the definition as this says that one x ∈ X cannot be associated with 2 or more elements of Y. Thus we can call the y value corresponding to a particular x under the rule f by the name f(x) (read f of x) since there is only one such y. However, associating 2 elements of X with the same y ∈ Y and some elements of Y not corresponding to any element of X are allowed as they are not ruled out in the definition. The fact that the correspondence goes from the domain to the codomain is indicated by the notation f : X ⟶ Y.

1.1. Functions written on the right

If we are given a function f : A ⟶ B and we write y = f(x) then we say we have written the function on the left. Another notation is to write y = xf and say we have written the function on the right. You have probably seen both but perhaps have not realized it. Before we give some examples, let’s also introduce some more notation. If y in the codomain is such that y = f(x) for x in the domain, then we write x ↦ y.
Consider the function sin : R ⟶ R  defined by x ↦ sin x . This function (as we have shown) is typically written on the left. Following the same principle, then what would happen with the squaring function? We’d have (( )^(2 )): R ⟶ R defined by x ↦ (( )^(2 ))x by writing the function on the left. If, though, we write the function on the right we would get the more familiar x ↦  (x^(2 )).
We don’t wish to imply writing functions on the left is preferable to writing functions on the right or vice-versa. There are advantages and disadvantages to both notations.
Some other functions that are written on the right include the factorial function ( n ↦ n! ) and applications of functions on a calculator (for example you probably enter then number first and then press the function key).

Definition. 1.1. Functions are essentially special cases of bianry relations.

Definition. 1.2. A function from a set A to set B is a relation f between A and B satisfying conditions:
1) ∀ x ∈ A , ∃ y ∈B s.t. (x,y) ∈ f
2) ∀ x ∈ A , ∃ y,z ∈B (x,y)∈f and (x,z)∈f  ⟹  y=z

in other words a function(mapping) f: A ⟶  B is a subset of A×B where each member of A appears exactly once. Where A is domain and B is codomain.

Definition 1.3. For a subset A ⊂ X we use f(A) to mean the set { y∈Y | ∃ x∈A ( y=f(x) ) } called the image of A. (Some authors use (f^→)(A).)

Definition 1.4. The set f(X) is called the range of f.
 
While it is always the case that f(X) ⊂ Y, in general they need not be equal. It is important to distinguish A ⊂ X while f(A) ⊂ Y.

Definition 1.5. For a subset B ⊂ Y  we use (f^(-1))(B) to mean the set  { x∈X | f(x) ∈ B } called the inverse image of B. (Some authors use (f^←)(B).) Keep in mind that B ⊂ Y while (f^(-1))(B) ⊂ X.

1.2. Note

If (a,b) ∈ f  ⟹  f(a) = b             

b is an image of a
a is a preimage of b           
 f is said to map a to b.

1.3. Functions on the right and composition

For functions written on the right the order in which we write the functions in the composition is reversed. Also, we don’t use the circle between the letters representing the functions. So if f : X ⟶ Y , and g : Y ⟶ Z then the composite map is written as fg and its value at x is xfg.

Example 1.3.1. 
Using real valued functions, take the functions defined by x ↦  (x^(2 )) and x ↦  (x^(3 )) . The composition is x ↦  ((((x^2) ))^3) or more simply x ↦  (x^(6 )) .

2. Describing Functions

There are many ways to describe or write functions. The method used depends on many factors such as the domain of the function, the complexity of the function or even the subject matter in which the function arises. We describe a few common methods here.

Method 2.1.:
If the domain is small we might just list all function values. Let X = {1,2,3} and Y = {a,b,c,d}. If I tell you that f(1)=b, f(2)=b and f(3)=d then I have completely defined a function  f : X ⟶ Y. Observe that this f neither 1-1 nor onto and has range {b,d}, a proper subset of Y.

Example 2.1.1. :
f : S ⟶  T where S = T = {1,2,3} and f(1)=2, f(2)=3, f(3)=1.

Method 2.2.:
We could list all pairs in the graph of f, again if the domain is small. The function in Method 2.1. could be given by {(1,b),(2,b),(3,d)}.

Example 2.2.1.:
f : S ⟶  T where S = T = {1,2,3} and f = {(1,2),(2,3),(3,1)}.

Method 2.3.:
Quite often simple functions like the example in Method 1 are indicated by just listing the elements of both the domain and codomain and connecting x values to function values by arrows. Here's how that's done.

Example 2.3.1.:

bipartite={1->"b",2->"b",3->"d","c"->"c","a"->"a"};
GraphPlot[bipartite,VertexCoordinateRules->{1->{1,3},2->{1,2},3->{1,1},"b"->{2,2},"a"->{2,3},"c"->{2,1},"d"->{2,0}},VertexLabeling->True,DirectedEdges->True,SelfLoopStyle->None,PlotStyle->{Arrowheads[{{0.08,0.8}}],Thickness[0.01]}]

Method 2.4.:
For numerical functions, a formula might be given in terms of x that calculates the value of f(x). For X = Y = ℝ the set of real numbers, y = f(x) = (x^2) + 3 would define f : ℝ ⟶ ℝ . Since f(2) = (2^2) + 3 = 7 , the point (2,7) would be a point in the graph but there certainly are too many points to list as in Method 2.

Example 2.4.1:

 g : ℕ ⟶  ℕ where g is defined by: 

g(x) = ({{{, ({{x+3,, x⩾5}, {x,, x<5}})}})

Example 2.4.2.:

g : ℤ ⟶  ℕ , g(x) = |x| 


Method 2.5.:
A picture of the graph in Method 4 would be a good way to visually represent f instead of just supplying the formula. The picture is simple a plot of the points (x,y) in the plane  R × R that satisfy the equation y = (x^2) + 3 .

Example 2.5.1.:

y : ℝ ⟶  ℝ
y = (x^2) + 3

Plot[n^2+3,{n,-5,5},AxesLabel->{Style["x",Bold,10],Style["Y",Bold,10]},PlotStyle->Directive[Red,PointSize[Large]],AxesOrigin->{0,0}]

Method 2.6.:
It is sometimes possible to describe a function in words without resorting to lists, formulas or pictures. For example, the air temperature where you are sitting right now can be considered a function of time. That is, to each point in time we associate the corresponding temperature at that time. The domain consists of whatever scale is used to record time (12 or 24 hr. clock, minutes or fractions of hours, etc.) and the range is a subset of the real numbers (whatever temperature scale is used). This is a function by definition, yet you probably don't have a formula for this correspondence (well, unless the temperature is constant where you are).

Example 2.6.1.:
S is a set of all people in your Hometown, T is the set of SS#
f: S ⟶  T Yes and No associates person to his SS#

3. Special functions

Definition 3.1. Composite map:
If  f : X ⟶ Y and g : Y ⟶ Z we can form a new function called a composite map denoted by g ◦ f : X ⟶ Z . The symbol g ◦ f is read as " g circle f ". The composition is accomplished by defining g ◦ f = g(f(x)) ∈ Z  for each x ∈ X.

Definition 3.2. Onto functions; Surjective: 
We call f a surjection or onto if every y ∈ Y corresponds to some x ∈ X , that is, f(X) = Y.

Let f : S ⟶  T. We define the range of f, denoted R as a subser of T, and R is the set of all images of elemets of S under f. If the range coincides with the Codomain then the function is called onto or surjective

Example 3.2.1.:
g : ℤ ⟶  ℕ , g(x) = |x| function is surjective

Example 3.2.2.:
(b) Cities in the world and countries...

Definition 3.3. One-to-one functions; Injective: 
A function  f : X ⟶ Y is called an injection or one-to-one (also written 1-1) if different x values get mapped to different y values. So if (Subscript[x, 1]) ≠ (Subscript[x, 2]) then f((Subscript[x, 1])) ≠ f((Subscript[x, 2])). this is equivalent to the contrapositive, if  f((Subscript[x, 1])) = f((Subscript[x, 2])) then (Subscript[x, 1]) = (Subscript[x, 2]).

A function f : S ⟶  T. is 1-to-1 or injective, if no member of T is the image under f or two distinct elements of S.

Example 3.3.1:
g : ℝ ⟶  ℝ,  g(x) = (x^3)  is  1-1.

Example 3.3.2:
h : ℝ ⟶  ℝ,  h(x) = (x^2)  is not injective.

Example 3.3.3:
k : ℕ ⟶ ℕ,  k(x) = (x^2)  is injective.

Definition 3.4. Bijective functions: 
A bijection is used for functions that are both 1-1 and onto.
The set of ordered pairs {(x,f(x)) | x ∈ X } ⊂ X × Y is the graph of f.

Example 3.4.1:
g : ℝ ⟶  ℝ,  f(x) = 3x + 2  is bijective.

Definition 3.5. Inversible functions: 
Let f : S ⟶  T be a functions ( mapping from S to T ). If the inverse maping from T to S defines a function we say that f is inversible.

Theorem 3.5.1: A function f is inversible if and only if f is a bijection:

Example 3.5.1: 
f : ℕ ⟶ ℕ
 f(x) = x  ⇒ (f^(-1))(y) = y
 
Example 3.5.2: 
f : ℝ ⟶  ℝ
f(x) = a.x  (a ∈ ℝ, a ≠0)  ⇒  (f^(-1))(y)  = (y/a)

4. Inverse Functions

If  f : X ⟶ Y is 1-1 and onto then the correspondence that goes backwards from Y to X is also a function and is called f inverse, denoted (f^(-1)). As this is the symbol used for inverse image of a set it must be clear from the context how the symbol is being used. This map is easily described by (f^(-1)): X ⟶ Y and (f^(-1))(y)=x if and only if y=f(x). So if f(3)=5 then (f^(-1))(5)=3 automatically. If f(π) = - (Sqrt[123])  then (f^(-1))( - (Sqrt[123])) = π . In terms of pairs this says if (17,-8) is in the graph of f then (-8,17) is in the graph of (f^(-1)).

This relationship is easy to remember for real functions since switching coordinates of a point in the plane puts you at the reflection of the original point about the line y=x. Thus the graph of (f^(-1)) must be the reflection of the graph of f about the line y=x. This is a great help if the graph of f is already known.

4.1. Reflecting a graph over the line y=x

This is how the graph of the exponential function f(x) = (e^x) (in orange) is reflected over the line y=x to obtain the graph of (f^(-1))(x) = ln(x) (in blue) the natural log function.

Plot[{Log[x],Exp[x],x},{x,-2,2},PlotLegends->"Expressions",PlotRange->{-2,2}]

It’s the 1-1 condition that is really critical for constructing an inverse function. If f is 1-1 but not onto we can simply replace the codomain with the range f(X) so that f : X ⟶ f(X) is then 1-1 and onto so we can talk about an inverse (f^(-1)): f(X) ⟶ X.

There are some obvious questions that arise here. What are the proper domain and range for an inverse function?

4.2. Domains of function and inverse

There is an interesting relationship between the domain and range values of a function f and those of the inverse function. The connection is directed related to the fact that there are corresponding points in the graph f and the graph of (f^(-1)) that have their coordinates switched. If (x,y) is in the graph of f then (y,x) is in the graph of (f^(-1)). This says that the domain and range values must be switched. That is, the values in the domain of  (f^(-1)) are the range values of f, while the range values of  (f^(-1)) are the domain values of f. Of course, this must be the case since f : X ⟶  Y while (f^(-1)): Y ⟶  X but thinking about the graphs gives a nice geometric interpretation. 

Look below at the graphs of f(x) = (Sqrt[x+3]) - 1 with domain { x | x ⩾ -3 } and range  {y | y ⩾ -1 } (shown in red) and its inverse (f^(-1))(x) = (((x+1))^2) - 3 with domain  { x | x ⩾ -1} and range {y | y ⩾ -3 } (shown in blue).

a=ParametricPlot[{u,Sqrt[u+3]-1},{u,-3,4},PlotStyle->Red];
b=ParametricPlot[{u,(u+1)^2 - 3},{u,-1,4}];
Show[a,b,PlotRange->{{-3,3},{-3,3}}]

Given a formula for f, how does one find a formula for (f^(-1))?

4.3. Formula for inverse function

If we are given a formula for a 1-1 function f : R ⟶  R as y=f(x) then there is an algebraic method that attempts to find a formula for (f^(-1)). Whether or not the method is successful usually depends on whether or not the algebraic steps can be carried out. The basic idea is this. Since a point (x,y) in the graph of f satisfies the equation y=f(x), the point (y,x) in the graph of (f^(-1)) should satisfy the equation x=f(y). The only problem is can you solve this for y. That just means can you algebraically solve x=f(y) for y in terms of x. If you can, you will have y = (f^(-1))(x) , the formula for the inverse function. So the steps are:
1) write down y=f(x);
2) switch x and y to get x=f(y);
3) solve for y to get y = (f^(-1))(x).

Example 4.3.
Let y = f(x) = 2(x^3)- 7 a 1-1 and onto function from R to R. Here are the steps:
1) y = 2(x^3)- 7
2) x = 2(y^3)- 7
3) solving for y:
 2(y^3) = x+7
 y = ((x+7)/2)
 y = ((((x + 7))/2)^(1/3))
 
 so we get y = (f^(-1))(x) = ((((x + 7))/2)^(1/3))

Can a formula always be found?

4.4. Inverse function problems

There are a couple of ways in which an attempt to find a formula for (f^(-1)) from the formula for f could fail.

First, if f is not 1-1 then the method should fail! Here’s what could go wrong. Consider y = f(x) = (x^2) (a parabola) with domain R and range { y | y ⩾ 0 }. This function is not 1-1 on its domain so it should not have an inverse. If we try to find (f^(-1)) we are stopped at some point because of this. Try it.

1) y = (x^2)

2) x = (y^2)

3) y = ± (Sqrt[x])

Well, we solved for y but the solution was not unique. As you can see, we get two y values for every positive x value and that’s not a function. Each x in the domain must be associated with exactly one y value in the codomain.

A common way to get around this problem is to simply restrict the domain so that the resulting function is 1-1. If we consider y = (x^2) with domain {x | x ⩾ 0 } (the right half of t he parabola) and range { y | y ⩾ 0 } then we do have a 1-1 function. Now we can find an inverse.

1) y = (x^2)

2) x = (y^2)

3) y = (Sqrt[x])

So we get y = (f^(-1))(x) = (Sqrt[x]) with domain {x | x ⩾ 0 } and range { y | y ⩾ 0 }.

Second, even when an inverse exists you might not be able to do the algebra required to find a formula for it. Consider y = f(x) = (x^7)+ 5x. This function is 1-1 on R but finding (f^(-1)) requires solving the equation x = (y^7)+ 5y and you are not going to do that.

Actually, the ability to solve an equation algebraically is sort an ambiguous notion if you look at it this way. The function y = f(x) =cos(x) with domain {x | 0 ⩽ x ⩽ π } is 1-1 and has an inverse. Can you solve  x = cos(y) to find it. Well, if you consider making up a new symbol (cos^(-1)) in order to write down y = (cos^(-1))(x) as ‘’solving’’ the equation, then yes you can solve it. If you think about some other symbols you have seen, like √ or  log , you will see that these are just bits of notation that are used to “solve” for an inverse function ( (Subscript[log, b])(x) being an inverse for (b^x) ). If I push this idea farther (perhaps a little too far) I could claim that I solved the equation x = (y^7)+ 5y from above by making up a name, oh say Fred, and claiming that y=Fred(x) is the inverse of y = f(x) = (x^7)+ 5x. But let’s stop there.

If a function is claimed to be the inverse of a given function, this claim can be checked by a pair of well-known formulas that tell exactly how f and (f^(-1)) fit together under composition. For f : X ⟶  Y 1-1 and onto we always have:

∀x∈X  ( (f^(-1))◦ f(x) = x )  and ∀x∈Y  ( f◦ (f^(-1))(x) = x )

If x∈Y looks strange at first, keep in mind we used x∈X and y∈Y earlier only to emphasize the fact that we had two elements that came from two possibly different sets. In general, we can call elements of a set by any name we choose. Here we have two separate equations, so it’s all right to use x∈X in one of them and x∈Y in the other. It is easy to verify these properties. For the first one, start with letting  (f^(-1))◦ f(x) = z . We would like to show that z=x. Since (f^(-1))◦ f(x) =  (f^(-1))(f(x)) = z is equivalent to f(x)=f(z) by the definition of inverse, we are done as the 1-1 property says then that z=x. The second property has the same proof.