 So now we're ready to define the notion of a function from a set theoretic prior to saying that though I should remind the viewer here the definition of a relation from the set theoretic point of view. In the previous video we had remind we reminded the viewer about the notion of a Cartesian product right the Cartesian product of A and B will be the set of all ordered pairs from things coming from A and things coming from B. A relation is is simply just a subset of this ordered pair. And so we would say that R is a relation on A and B as the subset of the ordered pair. And so the the the relation R we want to think of is that's a set of ordered pairs. It might not be the proper subset. So we don't necessarily expect all ordered pairs to be in there, although that is an acceptable possibility. So the relation is just a set of ordered pairs. And we say that an element A which is in capital A and little B which is in capital B. We say that A is related to B. If that ordered pair A comma B is inside of the relationship. And typically this will be denoted by A or B. We put the relation as a symbol between the two two elements which are related. Say A or B. Now of course if A comma B is an ordered pair that's not in the relationship we would say this happens if and only if A R B's A R slash B. So A A not R B. We can say something like that as well. Alright so that's a relationship. That's a very broad definition. There's lots of different types of relationships one could study. Right now our focus is to be on the special function relationship. But in future videos we'll talk about equivalence relationships. We'll talk about partial orders which are different ships on between two sets. And of course we could also take that the set A and B are actually the same set. And so you could have relationships of a set on itself. But for the moment being let's focus on the function relationship. So take two sets A and B and again the order does matter right. A is the first one B is the second one. So we say that a relation which we're going to call it F here F for function. We say that a relation F on A and B is a function or sometimes it's called a mapping. And the direction does matter. It's a function from A to B. So there is this idea of flow right here. A flows to B here. And so we will denote that indicating that flow. F is a function from A to B or sometimes you'll see people draw the little F above the arrow. That's okay too if you want to do that. So what's a function? It's a relationship from A to B such that for each element A inside of the first set capital A there exists exactly one ordered pair of A, B inside of F right there. So for every element in the set A there's exactly one ordered pair that has A as the first parameter right there. And which case we would then say that A is related to B and the way we typically denote that's in the following way. So if A comma B is inside of the relationship F then we would say that F of A equals B. And so the symbol F of A we can use interchangeably with B here. And since there's exactly one ordered pair that has A in the first slot there's never going to be a time where I say F of A equals B1 and F of A equals B2. The notion of a function requires this uniqueness for the elements in the first in the first slot. Now this element B which is connected to A we refer to this as the image of A and like we saw it's denoted as F of A. And we also might write this in the following manner we might say if and only if F maps A to B. So we draw this little arrow but there's always this vertical line attached to the left side of the arrow showing the flow right there. You can you can drop the F if by context it's clear which function we're talking about. If there's multiple functions then you probably need to write F right there so we can see it. A little bit of vocabulary that the set that we are leaving that is the set that the first set A we refer to this as the domain of the function and then the second set B that you're flowing into that is commonly referred to as the co-domain of the function. And so if we re-express the idea of a function what we mean is a function is a function if the domain has a unique image. Every element of the domain has something to show you to it. That means everyone in the domain is connected to some element of B. At least one element but also at most one element. Now one has to be careful here. When it comes to the definition of a function we are specifying a uniqueness of relationship on things in the domain. In terms of the co-domain we have no connection there whatsoever. At least not for the definition of function. It could be that multiple elements in the domain relate to the same element in the co-domain. There could be like some A1, A2, A2 there that both map to the same element B. We don't forbid that when we define a function. We just need that f of A1 is defined that could be B. We need f of A2 to be defined that could also be B. So there's no uniqueness of image in the definition of a function. Also there could be things in the co-domain right? You have things in the co-domain over here. This is our co-domain B. You have some domain over here A. It could be that this thing is mapping to this one. This one maps to this one. This one maps to this one right? And there could be someone in the co-domain that is not related to anyone in the domain. The function definition doesn't require that. The stipulation is uniqueness on relation for the domain. There's nothing about uniqueness of relation on the co-domain. We'll actually come back to that issue a little bit later in the next video. And because of this it often makes sense to define the image of the function. Now we're overloading this word a little bit. We've talked about the image of an element in the domain. But the image of the function, this is sometimes called the range. This will be the set of all images of the elements right? So as A ranges over the elements of the domain, you take the set of all images. That set is also called the image of A. Sorry the image of f often is denoted f of the whole set, the whole domain A right there. In like calculus settings, pre-calculus settings this is often called the range. But as people often use the word range to describe the image of the function and the co-domain of the function, in higher mathematics we often step away from the word range because again it can be a little bit confusing for more mathematical settings. So we'll typically call this the image of the set, the image of the function I should say. And so the co-domain and the image are not typically the same set although it is possible that is the case. But that's not always the case. If we ever have if we have any subset of the domain, for example let's say that y is some subset of the domain, we can then talk about the image of y f of y. This of course will naturally be a subset of the of the image of the whole function in which case we would define this set right here to be the set of all values f of y where y is the side of y right. So the image of the function is if you take the image of the entire domain but any subset of the domain we could also talk about the image of that set. And this process is also reversible. If we take these a subset of the co-domain call it x we can talk about the reverse image or the pre-image that's the word we're going to use here. With the pre-image this is also something that we don't often talk about in like calculus notions of function which is honestly a poor notion of functions we'll get into that a little bit more in this lecture. The pre-image which will write f inverse of x this would be the set of all elements a in the domain such that f of a is inside the x right there. So we think of x as a set of images it's part of the co-domain right. We want to think of x as a set of images and so the pre-image is going to be the set of all elements which map into x via this map x the map f excuse me. Now one has to be a little bit careful right because although x is a subset of b there could be things in the co-domain through which nothing maps to it. And so who's going to map to that little x there? Well maybe it's no one it could be that the pre-image of a non-empty set could be empty depending on the function. And also there could be multiple elements which map to these elements multiple elements in a that map to things inside of x. And so if you take the pre-image of a single element inside of the co-domain that could be empty if nothing maps on to it or it could be multiple elements if there's a lot going on there. We'll see some examples and play around with these things in the not too distant future here. One thing I do also want to make if you see the set a to the b so we take our sorry b to the a excuse me over that backwards order matters here. So we have a set b and superscript itself as a set. This is going to be the set of all functions of the form a to the b. A flows to b right here and so this might seem a little bit backwards. The a comes second as the superscript and the reason for that's the following. If a is a finite set which contains a mini elements and b is a finite set that contains b little elements then the set b to the a which is the set of functions from a to b it'll contain b to the a mini elements and as usual this denotes the cardinality of the sets here and basically the idea is the follow if you have a finite set right here and a finite set right here here's a here's b we have some objects in the domain do do do right we have to make a choice like okay a this one has to go here this one has to go here this one has to go here something so for each element in the domain we have to make a choice about how many where should those things go right so for the first element you have b options for the second element you have b options for the third element you have b options etc etc etc and so you're how many if you put all those together because these are independent choices for your general function you're going to have b times b times b times b times b how many b's are there well there's a mini b's and that's b to the a right there so let's look at some examples of functions now i'm going to start off with some examples we might have seen from calculus because that's probably one of our first exposures or at least in pre-calculations so in calculus we often define functions using formulas and this is sort of a poor way of doing it so we might say something like f of x equals x cubed and g of x equals e to the x the reason why i say this is a poor way of defining functions this doesn't specify the domain or codomain of the function which is an important concept but ignoring that issue for the moment when you define a function by a formula what you mean is if you take any number in the in the domain like say for the first one if you want to take say three f of three is just defined to be evaluate the formula where all the x's are replaced with your input right here this three so we get three cubed which equals 27 so f of three is 27 for example f of two would equal eight two cubed if you wanted to work with the function g g of zero would be e to the zero which is equal to one so it gives us the formula gives us how we evaluate the function but it turns out that specifying the domain does actually make sort of an important thing and now in calculus they usually follow the domain convention which says that you define the domain to be the set of real numbers for which the formula is well defined unless stated otherwise so for the function f you would probably say something like i'm taking all real numbers and then what's the output what's the codomain well in calculus you typically set the codomain to equal the range but then you have to figure out what the range is for x cubed you can get away with all real numbers for g though right you can take in all real numbers as your input but the output well for exponential the output would only be positive reels so you could end up with zero to infinity right but you could also let's call this g one you could also take g two to be the function where you take input as reels and you output a real the fact that our function the exponential function doesn't hit every real number doesn't actually forbid the codomain from being all real numbers and i should mention that these two functions g one and g two are considered different functions because their codomains are different it doesn't matter if they're derived by the same formula because the function is a rule between two sets the domain and the codomain if you switch the domain or the codomain the two functions are automatically different functions and if the two functions have the same domain and codomain they'll be equal if the rule is the same if the set of ordered pairs is all the same and so i mean again in the context of calculus the domain and codomain are usually not stated but we kind of choose do we kind of choose the domain to be maximal in the in the codomain to be minimal this can get into some problems right let's say we take the function f one you know we might say something like f of x equals one over x well in this situation again that typically would probably take the domain to be all numbers except for zero that's kind of the biggest allotment you can use there and then you take as the output well it would have to be kind of the biggest you could choose would be something like this zero is not an output there but this should be specified with the function calculus keeps us somewhat ambiguous um if we did something like a square root square root of x uh in that situation calculus if you want sort of like the maximal domain you would take zero to infinity and this is mostly so that the output is also real that's part of that domain convention in in real value calculus you want all input and output to be real numbers so for the square root even though the square root of negative one is defined it's out the output wouldn't be a real number so we end up with something like this so using tricks and other observations we can come up with an appropriate domain our codomain but be aware switching the codomain and domain does actually change the function and so this will be much more important as we talk about functions being surjective or injective we'll get to that in a moment talk just about when it comes to functions is the idea about being well defined because after all a function is a relation it's a subset of the ordered pair of the of the cartesian product now our relation is a function because a function a relation sorry a relation is a function is a relation and a relation is a set because the relation by definition is a subset of a cartesian product so as such we have to make sure the definition of the function which is a set is well defined and so you have issues like the following if one tried to define a function from the rational numbers to the integers one might define the following situation f of p over q equals p that is will just record the numerator but what happens when you take two different representations of the same rational number one half and two fourths are considered the same rational number but if you take f of one half it should give you a one f of two fourths should be two so those things are truly equal to each other we should expect that the mapping would be the same irrelevant so this is the concern about this function is not well defined and this this happens a lot in particular with equivalence relationships right if our set is a set of equivalence classes we want to make sure that our definition doesn't depend on the representative but it depends on the class itself and this equivalence relationships in a future lecture but as we've likely seen this before I don't think it's too obnoxious to bring it up right now one should be very cautious when we define a function we have to make sure that it is well defined