If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

A more formal understanding of functions

A more formal understanding of functions. Created by Sal Khan.

Want to join the conversation?

  • female robot amelia style avatar for user madeline blanchard
    this video is long!! I'm so confused!! Help, can someone explain what this means? Codomain? Range?
    (7 votes)
    Default Khan Academy avatar avatar for user
    • old spice man green style avatar for user newbarker
      An example: f(x) = x², x ∈ R. Let's break it down...

      f(x) = x²
      f is a function. Think of it like a machine that accepts any number (we use the placeholder x for that number) and produces another number which is the square of the number (x times itself).
      x ∈ R
      This means that x is a member of the real numbers. The real number system is a classification of numbers that include whole numbers, negative numbers and and all decimals, so x can be any number. This is called the domain of the function.

      (So when you see f(x) = x², x ∈ R you read it as "f of x equals x-squared where x is a member of the reals").

      The codomain is also R. This means that our function f spits out numbers from the same classification as the ones it accepts. It so happens that because the numbers are squared that they must be greater than or equal to 0. This is where range comes in... it describes which members of the codomain f will actually output. In our example, the range can be specified using either one of these notations (both of which mean greater than or equal to zero):
      0 ≤ f(x) ≤ ∞
      (58 votes)
  • leaf green style avatar for user boris.s.jensen
    At , shouldnt the range be {2}, instead of 2. Since the range is a set of numbers, not just a number?
    (22 votes)
    Default Khan Academy avatar avatar for user
  • male robot hal style avatar for user Danny Flynn
    I was just looking at wikipedia and want to be clear on this. Are the R2 and R3 spaces mentioned in this video what are formally called two dimensional and three dimensional Euclidean space respectively?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • male robot donald style avatar for user Jeremy

      Mostly yes. R2 and R3 could easily represent 2 dimensional and 3 dimensional space, respectively, but they don't HAVE to represent "physical" space. For example, if you have a function (maybe heat transfer rate?) that depends on say, time and temperature, that could be considered "3-dimensional" problem where the three dimensions are time, temperature, and heat transfer rate. You might find it useful to work with the problem in terms of 3x3 matrices and 3x1 vectors, even though the vectors don't really represent vectors in "space" the way you are probably used to thinking about vectors.

      In this case, none of the 3 dimensions in the problem represent physical spacial dimensions. So I guess the short answer is R2 and R3 CAN represent two dimensional and 3 dimensional euclidean space, and that is what the often DO represent… they don't HAVE to represent that.
      (16 votes)
  • ohnoes default style avatar for user Brian Lee
    What's codomain? I know domain and range in kumon, but I don't know what codomain means. Can you tell me a definition, please?
    (7 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user Pete Halton
      A codomain of a function is any set containing the range of the function - it does not have to equal the range. For example the function y=x² has as a codomain the set of real numbers, which is a set containing the range (y≥0), but is not equal to the range. We can say y=x² maps (sends) the set of real numbers into the set of real numbers, without specifying the range.
      (8 votes)
  • blobby green style avatar for user tanya
    How do I determine the value of the dependent variable when the independent variable is zero.
    (7 votes)
    Default Khan Academy avatar avatar for user
  • mr pink red style avatar for user Scott
    I am not familiar with the term Sal uses at about . What is a 'tuple'?
    (5 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user Adam
      Sal used this term also in some of the videos on vectors. The wikipedia entry on Tuple is very helpful. Below are pasted the parts I think are sufficient to get the meaning:

      "In mathematics and computer science, a tuple is an ordered list of n elements. In set theory, an (ordered) n-tuple is a sequence (or ordered list) of n elements, where n is a non-negative integer. ...

      The term originated as an abstraction of the sequence: single, double, triple, quadruple, quintuple, sextuple, septuple, octuple, ..., n‑tuple, ..., where the prefixes are taken from the Latin names of the numerals. The unique 0‑tuple is called the null tuple. A 1‑tuple is called a singleton, a 2‑tuple is called an ordered pair and a 3‑tuple is a triple or triplet. The n can be any nonnegative integer. For example, a complex number can be represented as a 2‑tuple, a quaternion can be represented as a 4‑tuple, an octonion can be represented as an octuple, (many mathematicians write the abbreviation "8‑tuple") and a sedenion can be represented as a 16‑tuple.

      Although these uses treat ‑tuple as the suffix, the original suffix was ‑ple as in "triple" (three-fold) or "decuple" (ten‑fold). This originates from a medieval Latin suffix ‑plus (meaning "more") related to Greek ‑πλοῦς, which replaced the classical and late antique ‑plex (meaning "folded")."
      (10 votes)
  • leaf green style avatar for user Thomas Varley
    So for the final function (h), what is the range?
    (6 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user sahasouradeep01
    how to find a gradient of a linear function?
    (4 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Marybeth  Langin
    How can you tell from an equation if it's a linear function?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Miles Ford
      A linear function CAN be arranged into the form y=mx+c, but it doesn't have to be presented in that form. 3x+2y-4=0 is a linear function. y^2=3x+4 is not.

      To identify a linear function from just looking at the equation the order (power) of the variables needs to be 1, i.e. x and y. So no x^2, x^3, sqrt(x), 1/x, etc... and the same for y.
      (1 vote)
  • leaf green style avatar for user Rajeswari Murukan
    Isn't the range of the function f(x)=x^2, all +ve Real numbers..as -ve numbers can't be the square of any real number..?
    (4 votes)
    Default Khan Academy avatar avatar for user

Video transcript

I think you've been exposed to the idea of a function at some point in your mathematical career. But what I want to do in this video is explain it a little bit more formerly than you might be used to, and then relate it to some of the concepts of vectors and linear algebra that we've seen so far. A function really is just a relation between the members of one set and the members of the other set. So let's have some set x, and for every member of that set x I'm going to relate that member, or associate that member, with another member of a set y. So if I imagine that is my set x, and that this is my set y-- and y doesn't have to be smaller, that's just the way I drew it-- the function is just a relation. That if I just take a member of my set x, let's see that's the member that I'm taking, we're visualizing it as a point. This function will say, OK you gave me a member of x, then I will give you a member of y associated with that member of x. So the function will say, you give me that, then I will map it to that member right there. And that really just means relating it to, or associating with another member of y. And if you'd give me some other point right here, I'll relate it to another member of y. I might even relate it to the same member of y. And so this notation just says this is a mapping from one set x, and I'm speaking in very general terms, to another set y. And so you're probably saying, Hey Sal, this is very abstract, how does this relate to the functions that I've seen in the past? Well let me just write down a function you've probably seen a lot in the past. You've dealt with f of x is equal to x squared. How would we write this in this notation? Well this is a function, assuming that it's kind of the traditional way that you see it. Let me just write with the f, I was going to write it with the g of x, just so this doesn't always have to be an f, but I think you get that idea. In this case f is a mapping from real numbers-- the real numbers are everything that I can put in here-- actually this is part of the function definition. I could constrain this to just be integers, or just be even numbers, or just be even integers. But this is part of the function definition, I'm defining the function to be a mapping from real numbers. I'm saying you can put any real number here, and it's going to map to real numbers. So in this case, if x is real numbers, it's going to map to itself, which is completely legitimate. So if this is the real numbers-- and obviously the real numbers would go off in every direction forever-- but if this for real numbers, this function mapping is just taking every point in R and mapping it to another point in R. It's taking every point and associating with it its perfect square. And I want to make a very subtle notation-- or at least in my mind the first time that I got exposed to functions I was thinking, you give me an x and I square it, and I'm giving you the square of x. And that's true, you are doing that. But at least the way my brain worked, I kind of thought of it as I was changing my x into another number. And you can maybe view it that way, and that might actually be the best way to view it. But the mathematical definition I'm introducing here is more that I'm associating x with x squared. This is another function notation of writing this exact same thing. These two statements right here, this statement and this statement are identical. This statement you've probably never seen before, but I like it because it shows the mapping or the association more, while this association I think that you're putting an x into a little meat grinder or some machine that's going to ground up the x or square the x, or do whatever it needs to do to the x. This notation to me implies the actual mapping. You give me an x, and I'm going to associate another number in real numbers called x squared. So it's going to be just another point. And just as a little bit of terminology, and I think you've seen this terminology before, the set that you are mapping from is called the domain and it's part of the function definition. I, as the function creator, have to tell you that every valid input here has to be a set of real numbers. Now the set that I'm mapping to is called the codomain. The obvious question that you're probably asking is, hey Sal, when I learned all of this function stuff in algebra II or whenever you first learned it, we never used this codomain word. We have this idea of range, I learned the word range when I was in 9th or 10th grade. How does this codomain relate to range? And it's a very subtle notation. So the codomain is a set that you're mapping to, and in this example this is the codomain. In this example, the real numbers are the domain and the codomain. So the question is how does the range relate to this? So the codomain is the set that can be possibly mapped to. You're not necessarily mapping to every point in the codomain. I'm just saying that this function is generally mapping from members of this set to that set. The range is the subset -- let me write it this way. It could be equal to the codomain. It's some subset. A set is a subset of itself, every member of a set is also a member of itself, so it's a subset of itself. So range is a subset of the codomain which the function actually maps to. So let me give you an example. Let's say I define the function g, and it is a mapping from the set of real numbers. Let me say it's a mapping from R2 to R. So I'm essentially taking 2-tuples and I'm mapping it to R. And I will define g, I'll write it a couple of different ways. So now I'm going to take g of two values, I could say xy or I could say x1, x2. Let me do it that way. g of x1, x2 is always equal to 2. It's a mapping from R2 to R, but this always equals 2. And let me actually write the other notation just because you probably haven't seen this much. g maps any points x1 and x2 to the point 2. This makes the mapping a little bit clearer. But just to get the notation right, what is our domain? What's the real number? That was part of my function definition, I said we're mapping from R2, so my domain is R2. Now what is my codomain? My codomain is the set that I'm potentially mapping to, and is part of the function definition. This by definition is the codomain. So my codomain is R. Now what is the range of my function? The range is the set of values that the function actually maps to. In this case, we always map to the value 2, so the range is actually just the value 2. And if we were to visualize this-- R2 is actually-- I wouldn't draw it as a blurb, I would draw it as the entire Cartesian space, but I'm just giving you an abstract notion. That's R2. If I really have to draw R, I'd draw it as some type of a number line. Actually let me do it that way just for fun, you don't normally see it written that way. But I could just draw R like that's R2, and I could just draw R as some straight line. So this is the set R. I could draw it like that as well, but let's just say this is set R. And my function g essentially maps any point over here to exactly the point 2. 2 is just one little point in R. My function g takes any point in R2, any coordinate, this is the point 3, minus 5, whatever it is. It always maps it to the point 2 in R. So if I think that point it maps it to the point 2. That's what g always does. So g's codomain-- you could say it's all of the real numbers, but it's range is really just 2. Let me do another example that might be interesting. If I just write h is a function that goes from R2 to R3, and I'll be a little careful here, h goes from R2 to R3. And I'll write here that h of x1, x2 is equal to -- so now I'm mapping a higher dimension space, so I'm going to say that that is going to be equal to, let's say my first coordinate or my first component at R3 is x1 plus x2. Let's say my second coordinate is x2 minus x1. And let's say my third coordinate is x2 times x1. Now what is my domain and my range and my codomain? So my domain by definition is this right there. My codomain by definition is R3. And notice I'm going from a space that has two dimensions to a space it has three dimensions, or three components. But I can always associate some point with x1, x2 with some point in my R3 there. A slightly trickier question here is, what is the range? Can I always associate every point-- maybe this wasn't the best example because it's not simple enough -- but can I associate every point in R3-- so this is my codomain, my domain was R2, and my function goes from R2 to R3, so that's h. And so my range, as you could see, it's not like every coordinate you can express in this way in some way. Let me give you an example. I could put some x1's and x2's here and figure it out. Let's do that. Let's take our h of-- let me use my other notation-- let's say that I said h, and I wanted to find the mapping from the point in R2, let's say the point 2 comma 3. And then my function tells me that this will map to the point in R3. I add the two terms, the 2 plus 3, so it's 5. I'd find the difference between x2 and x1-- so 3 minus 2 is 1-- and then I multiply the two, 6. So clearly this will be in the range, this is a member of the range. So for example the point 2, 3, which might be right there, will be mapped to the three dimensional point, it's kind of just drawn as a two dimensional blurb right there, but I think you get the idea, would be mapped to the three dimensional point 5, 1, 6. So this is definitely a member of the range. Now my question to you, if I have some point in R3, let's say that this is the point 5, 1, 0. Is this point a member of the range? It's definitely a member of the codomain, it's in R3. It's definitely in here, and this by definition is the codomain. But is this in our range? 5 has to be the sum of two numbers, the 1 has to be the difference of two numbers, and then the 0 would have to be the product of two numbers. And clearly we know 5 is the sum, and 1 is the difference, we're dealing with 2 and 3, and there's no way you can get the product of those numbers to be equal to 0. So this guy is not in the range. So the range would be the subset of all of these points in R3, so there'd be a ton of points that aren't in the range, and there'll be a smaller subset of R3 that is in the range. Now I want to introduce you to one more piece of terminology when it comes to functions. These functions up here, this function that mapped from points in R2 to R, so its codomain was R. This function up here is probably the most common function you see in mathematics, this is also mapping to R. These functions that map to R are called scalar value or real value, depending on how you want to think about it. But if they map to a one dimensional space, we call them a scalar valued function, or a real valued function. Which is pretty much all of the functions that you've probably dealt with up to this point in your mathematical career, unless you've taken some vector calculus. Now the functions that map to spaces or subspaces that have more than one dimension-- so if you map to R or any subset of R, you have a real valued function, or a scalar valued function. If you map to Rn, where n is greater than 1, so if you map to R2, R3, R4, R100, you're then dealing with a vector valued function. So this last function that I defined over here, h is a vector valued function. Anyway I think you now have at least the mathematical notational tools to understand what I'm going to do in the rest of this playlist, and hopefully you found this reasonably useful.