What is a function?

yes, they are more than just squiggly lines on a graph!

Ashley <3
8 min readJan 4, 2023

Preface

This article will be of use to those who have basic knowledge with sets and their applications. As I write more articles, I’ll update this section with useful articles to refer to that will help you to better understand this article!

You may want to read:

Sets! Part one → information about basic set applications

What is a function?

If you were to ask me what a function was a few months ago I’d probably grab a piece of paper, draw a graph and proudly draw a U-shaped line in the dead centre. Ta-da! And that is a function, I’d say to you with full confidence. And while this is true, it’s quite the informal way to define what a function is.

If you asked me the same question again, a better way to describe a function would be to say that a function exists if you put a number into an equation and it always has one answer. Think about it this way, when you plug a number into an equation f(x) using a calculator, you should always get one unique y value for every unique x value put into f(x).

If f(x) = 2(x) and x = 3

f(3) = 2(3) which always returns one output which is f(3) = 6.

f(3) is always equal to 6 and will never be equal to another output at the same time (in other words f(3) is not equal to 6 AND 5 or 6 AND 9999).

Lastly, we need to know that functions consist of a binary relation. If we have two sets, set X and set Y we refer to set X as the domain and set Y as the codomain. In a function, the x values would be in the domain and the y values would be in the codomain. This is because the domain represents a set of inputs and the codomain represents a set of outputs as a result of the domain. A binary relation says that our x values that belong in set X are related to our y values that belong in set Y if some condition exists that defines the relation.

Now that we have all this information we can formally define a function as the following:

A function from set X to set Y is a binary relation f from X to Y if for every x that belongs in the set of X, there is ONLY ONE y in the set of Y such that (x, y) belongs to f (this factor is what defines the binary relation of a function).

The pair of (x, y) values from the respective sets of X and Y is a subset of X x Y with a property that says that all the values in the set X (the domain) will be paired with a value from the set Y (the codomain).

If we define set X as X = {2, 3, 4} and Y = {a, b}, we could have:

f = {(2, a), (3, b), (4, a)}

We can see this is valid because the values 2, 3, and 4 in set X are all mapped to just ONE value. In other words, there is no such example where 2 maps to both a AND b.

Now let’s try another few examples that demonstrate what is NOT a function (using the sets defined above).

f = {(2, a), (3, b)}

What’s the problem with this? In set X, 4 is not mapped to any value in set Y.

Lastly:

f = {(2, a), (3, b), (4, a), (2, b)}

Uh oh! Yikes!! We can’t have the same x value that maps to two different y values :/ Therefore the ordered pairs (2, a) and (2, b) are not valid.

Notation

When looking at properties of functions (which will be explained below), it will be denoted as:

f : A → B

Typically a function is defined by f.

The whole line above states that f is a function from A to B.

A represents what can be inputted into the function and B represents the output of the function based on the inputs.

For example:

f : N → Z

Says that the function will input values from the set of natural numbers and can only output values from the set of integers.

Injective

Functions can be injective (otherwise referred to as one-to-one).

Injective functions are defined as:

if f(a) = f(b), then a = b

or we can take the contrapositive:

a != b → f(a) != f(b)

So in other words, if two values inputted into the same function give the same output, then a function is NOT injective. However, if all possible values being inputted into the function return unique outputs, then we can say that the function is injective.

So how do we prove that a function is injective?

We need to show that for ALL inputs a function can take, every output possible will be unique. So two inputs will NOT map to the same number.

The important thing here is that we demonstrate a proof working with arbitrary values. We want to show that if a != b, then f(a) != f(b). In other words, if the outputs of a function are different, then this implies that the inputs are not equal.

Ex. f : N → N defined on f(x) = x²

Remember, this says that our function will take in natural numbers as its input and will output natural numbers.

Here is how our proof will go:

Fix arbitrary values a and b in the set of natural numbers.

f(a) = f(b)

a² = b²

|a| = |b|

Note, we only take the positive root since we are in the set of natural numbers. As you can see this function is injective since two different values will always map to different outputs, as seen that a is not equal to b.

So how do we prove that a function is not injective?

To prove this, we want to show that two possible inputs map to the same output.

Ex. f : Z→ N defined by f(x) = x² + 1

Remember, this says that our function will take in integers as its input and will output natural numbers.

Here is how our proof will go:

Let a = 1 and b = -1

f(1) = ¹² + 1

= 2

f(-1) = (-1)² + 1

= 2

Since both 1 and -1 output 2, this function is NOT injective.

Surjective

A function can also be surjective (otherwise referred to as onto).

If we have a function f: a → b recall that a represents a set of possible inputs the function takes and b represents a set of all possible outputs the function can have.

A function is surjective if, for all possible values in set B, there exists a value in set A that maps to a value in set B.

It’s important to note that a function can be surjective and not injective at the same time. This is important because a surjective function can have multiple inputs that map to the same output, what’s important is that all possible outputs have an input value.

Let’s show an example of a surjective function:

Ex. f : R → R defined by f(x) = x³

Recall that this states that the function will take in real numbers as input and output real numbers.

In these proofs, we are given f(x) = … and we want to solve for x. Then we will put x into f(x) and see if it is equal to y. If this is the case, our function is surjective.

f(x) = x³, I change the f(x) to y (the same thing) just for clarity. So:

y = x³

³√y = x

Now let’s define x as x =³√y

f(³√y) = (³√y)³

The cubed root will be cancelled out and we are left with y.

f(³√y) = y

This shows that our function is surjective.

Now let’s prove that a function is NOT surjective.

Ex. f: N → N defined by f(x) = x²

Recall that this states that the function will take in natural numbers as an input and will also output natural numbers.

We are trying to show that this function is not surjective, so we need to come up with a counter-example.

Here is how our proof will go:

let f(x) = 3

3 = x²

√3 = x

However, √3 does NOT exist in the set of natural numbers, which means that the output of 3 does not have a possible input mapping to it, thus our function is not surjective.

Bijective

When a function is both injective AND surjective, it is also considered to be bijective. To prove this, we simply need to show that a function is both injective and surjective.

TLDR: prove that every value inputted into a function maps to a unique output and prove that all possible outputs have a possible input.

A nice example is defining f: Z → Z on f(x) = x.

Recall that our function will take in inputs and outputs that are integers.

Proving that it is injective is as easy as fixing two arbitrary values.

Fix arbitrary a and b in set Z.

f(a) = a

f(b) = b

as you can see a and b are not equal. If you input any number the output will also be the same, meaning that no two different numbers can have the same output.

If we prove that it is surjective we should see what input of x will be equal to y. This is as easy as inputting y into f(x).

Define x as x = y

f(y) = y

Thus our function is surjective because every possible input maps back to itself and so all unique inputs will have unique outputs.

And we just proved that a function is bijective!

A quick note✨

Hi, I’m Ashley! It’s been a while, but I’m finally back to publishing more articles in areas that I am interested in. I love writing here, it allows me to learn so many new things and practice my skills in areas I want to excel.

Right now I’m a freshman at Carnegie Mellon University studying computer science and currently, my interests are in programming, math, and neuroscience. I plan to publish more articles on these subjects so stay tuned!

My email is ashleycinquires@gmail.com. I just checked it recently and have come back to many messages. If you have any questions about anything, I’ll try to answer them. I do appreciate all the positive messages I’ve been sent and I’ll now definitely be more active via email. I love talking to people and learning about things from others so please reach out!!

I’ll see you soon :)

Ashley ❤

--

--

Ashley <3
Ashley <3

Written by Ashley <3

computer scientist, dog lover, peanut butter enthusiast, and probably a little too ambitious