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

Shifting functions examples

Sal analyzes two cases where functions f and g are given graphically, and g is a result of shifting f. He writes formulas for g in terms of f and in terms of x.

Want to join the conversation?

  • blobby green style avatar for user ranja18516
    at , why did Sal do x minus the horizontal shift and x plus the vertical shift? is there some kind of rule that explains why the horizontal shift must be subtracted and the vertical shift must be added?
    (21 votes)
    Default Khan Academy avatar avatar for user
  • leaf grey style avatar for user BlackSnow7
    Can someone please explain a little further what the second question is asking?

    what is the connection between g(x)= f(x+2)+5 and f(x) = sqrt(x+4)-2 ?
    (8 votes)
    Default Khan Academy avatar avatar for user
    • starky sapling style avatar for user ayramfouad
      so you're trying to write an expression in terms of x for g(x)* right?

      You have the expression for *f(x)* which is *f(x)+sqrt(x+4)-2
      and you have the expression for g(x)* after solving, which is *g(x)=f(x+2)+5.

      But now, you have f(x)* in your equation for *g(x)*. In order to get rid of that and have an equation for *g(x)* you need to solve both the equations.

      Now you put them all together like he did at by substituting for *f(x)=sqrt(x+4)-2
      with the expression for g(x)= f(x+2)+5.

      ~ f(x+2)=sqrt(x+2+4)-2

      ~f(x+2)=sqrt(x+6)-2

      ~f(x+2+5)=sqrt(x+6)-2+5

      ~f(x+2+5)=sqrt(x+6)+3

      ~and since f(x+2+5)=g(x)*

      --> *g(x)=sqrt(x+6)+3


      I hope I cleared something up instead of messing you up more.
      (8 votes)
  • piceratops tree style avatar for user Benjamin  Hysjulien
    Sal... Tell me if I am wrong... but the way I think about it is this is somewhat like completing the square. When you complete the square and find a value for C. Like Sal says you can't just willy-nilly add "C" without either adding that same amount to the other side or subtracting from the same side. In this case you are "extracting" a given value from X. This forces "X" to make up for it. For Example: If I have to have a pile of marbles that are equal to "X" amount, but I know I will have someone come along and take two marbles before I even start counting them, then I need to have X be equal to two more marbles. Substitute X for a number. I can either have X be equal to 10 or 12-2. Again... subtracting 2, forces my starting X value to be worth 2 more. Am I on the right track?
    (8 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Gobinath Periyasamy
    I can not visualise this 'negative' for vertical and 'positive' for horizontal. Can someone explain? Why we are shifting like this?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • piceratops sapling style avatar for user SpeedDragon
    I know that f(x)= √(x+4) -2.
    If we put x=√(x-4) -2 into f(x+2),
    I think it should be √(x+4) +2 instead of √(x+2+4)
    I'm really confused. Really appreciated someone can help me!
    (3 votes)
    Default Khan Academy avatar avatar for user
    • stelly blue style avatar for user Kim Seidel
      f(x)= √(x+4) -2 and you are trying to find f(x+2)
      The "x+2" is your input value. You replace the "x" in the function with "x+2"
      The "x" is inside the square root. So, that "x" changes to "x+2"
      f(x+2)= √(x+2+4) -2

      What you calculated is f(x)+2. The 2 in your scenario is not an input. You just added 2 to the entire function.
      Hope this helps you see the difference.
      (5 votes)
  • mr pants teal style avatar for user Annei Titania
    I was wondering; Why is it that in a normal number line, we would move to the right, being the positive side, but while during function shifts, we move to the left, and the other way around for the negatives? Why don't we move the same way according to the number line?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • aqualine ultimate style avatar for user Mandy
    I was wondering what would happen if the slope changed to a negative or other integer. On my homework, they have a reflected quadratic graph. But when I use the technique that Sal's showing, the slope gets left out...
    (2 votes)
    Default Khan Academy avatar avatar for user
    • leaf orange style avatar for user A/V
      In a polynomial system, there is no defined, stable slope. The closest of a slope in a polynomial graph is the derivative; however, that is later on in the year.

      So just to like set this out clear right,
      f(x) = x² is not a linear equation where you can get a stable slope. It's a polynomial.

      I hope I understood you're question correctly. If not please lmk
      (2 votes)
  • blobby green style avatar for user 1earth4ever
    Hi, it is first time I do math online . I can't figure out the format for typing my answers.
    I am going back to school in the fall and my class is given only online. I am not very good with computers, and I am really freaking out. Is there tutorials for this?
    (1 vote)
    Default Khan Academy avatar avatar for user
  • aqualine tree style avatar for user AniV
    At , why does Sal shift the blue line ( I honestly don't know what we call it ). Can't we shift the pink one?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • leaf orange style avatar for user A/V
      We can just call the blue line f(x) cause it's the name, likewise the pink line g(x).

      The question that's raised is "what is g(x) in terms of f(x)?" That means, we have to shift f(x) until it matches g(x).
      If the question asks "what if f(x) in terms of g(x)?" then we will have to shift g(x) until it matches f(x).

      Everything is dependent on what the question asks for, so watch out for that. Hopefully that helps !
      (2 votes)
  • blobby green style avatar for user Junyue0612
    why is it +4 instead of -4?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • starky sapling style avatar for user Elsa
      I think you are referring to the first example that he explained with the horizontal shift. The horizontal shift was -4 units. But the equation: g(x) = f(x - horizontal shift) + vertical shift translates to g(x) = f(x - [-4])+[-7]. Because there are two negative signs next to each other in (x - [-4]) the negative signs change to a positive or plus sign(+). Also, the +[-7] changes to just -7 which is what happens when a positive and negative are together in that order. The whole equation then changes to: g(x) = f(x + 4) - 7.
      (1 vote)

Video transcript

- [Voiceover] So we have these two graphs that look pretty similar, y equals f of x and y is equal to g of x. And what they asked us to do is write a formula for the function g in terms of f. So let's think about how to do it and like always pause the video and see if you can work through it on your own. All right, well, what I'd like to do is I'd like to focus on this minimum point because I think that's a very easy thing to look at because of them have that minimum point right over there. And so we can think, but how do we shift f? Especially this minimum point, how do we shift it to get to overlapping with g? Well, the first thing that might jump out of this is that we would want to shift to the left. And we'd wanna shift to the left four. So let me do this in a new color. So I would wanna shift to the left by four. We have shifted to the left by four or you could say we shifted by negative four. Either way, you could think about it. And then we're gonna shift down. So we're gonna shift, we need to go from y equals two to y is equal to negative five. So let me do that. So let's shift down. So we shift down by seven or you could say we have a negative seven shift. So, how do you express g of x if it's a version of f of x that shifted to the left by four and shifted down by seven. Or, you could say I have a negative four horizontal shift. I have a negative seven vertical shift. Well, one thing to think about it is g of x, g of x is going to be equal to f of, let me do it in a little darker color, it's going to be equal to f of x minus your horizontal shift, all right, horizontal shift. So x minus your horizontal shift plus your vertical shift. So plus your vertical shift. Well, what is our horizontal shift here? Well, we're shifting to the left so it's a negative shift. So our horizontal shift is negative four. Now, what's our vertical shift? Well, we went down so our vertical shift is negative seven. So it's negative seven. So there you have it. We get g of x. Let me do that in the same color. We get g of x is equal to f of x minus negative four or x plus four and then we have plus negative seven or you can just say minus seven. And we're done. And when I look at things like this, the negative seven is somewhat, it's more intuitive to me. As I shifted it down, it made sense that I have a negative seven. But first, when you work on these, you say, "I shifted to the left. "Why is it a plus four?" And though I think about it is in order to get the same value out of the function, instead of inputting, so if you want to get the value of x of zero, you now have to put x equals negative four in. And then you get that same value. You still get to zero. So that's, I know if that helps or hurts in terms of your understanding, but it often helps to try out some different values for x and see how it actually does shift the function. And if you just try to get your head on this piece, the horizontal shift, I recommended, you know, not even using this example. Use an example that only has a horizontal shift. It will become a little more intuitive. And we do, we have many videos that go into much more depth that explain that. Let's do another example of this. So here, we have y is equal to g of x in purple and y is equal to f of x in blue. And they say given that f of x is equal to square root of x plus four minus two, write an expression for g of x in terms of x. So first, let's me just try to, expression for g of x in terms of f of x. We can see once again, it's just a shifted version of f of x. And remember, I'll just write it in general. So g of x is going to be equal to f of x minus your horizontal shift plus your vertical shift. And so to go from f to g, what is your horizontal shift? Well, your horizontal shift is, if you take this point right over here, which should map to that point once we shift everything. Your horizontal shift is two to the left or you could say it's a negative two horizontal shift. So that should be negative two. And then, what is a vertical shift? Well, a vertical shift is removed, we go from y equals negative two to the y equals three. So we're shifting five up. So this is a vertical shift of positive five. So your vertical shift is five. So if we just want to write g of x in terms of f of x like we just did in the previous example, we could say g of x is going to be equal to f of x minus negative two which is x plus two. And then we have plus five. But that's not what they asked us to do. They asked us to write. They, whoops. They asked us to write an expression for g of x in terms of x. And so here we're actually gonna use the definition of f of x. So let me make it clear. We know that f of x is going to be equal to square root of x plus four minus two. So given that, what is f of x plus two? Well, f of x plus two is going to be equal to, everywhere we see an x, we're gonna replace it with an x plus two. Square root of x plus two plus four minus two which is equal to the square root of x plus six minus two. Well, that's fair enough. That's just f of x plus two. Now, what is f of x plus two plus five? So f of x plus two plus five is going to be in this thing right over here plus five. So it's going to be equal to square root of x plus six minus two and I'm going to add five, with a different color. So plus five, so plus five. And so what we end up with is going to be square root of x plus six minus two plus five is going to be plus three. So that is equal to g of x. Just as a reminder, what do we do here? First, I expressed g of x in terms of f of x. Let's say, hey, to get from f of x to g of x, I shift two to the left. Two to the left. So we're kinda intuitive, plus two makes it a shift of two to the left. This was minus two would be shifted two to the right. But like I just said in the previous example, it's good to try it some x's and to see why that makes sense. And then we shifted five up. So this was g of x in terms of f of x. Then they told us what f of x actually is in terms of x. So we said, "Okay, well, what is f of x plus two?" F of x plus two, we substituted x plus two for x and we got this. But g of x is f of x plus two plus five. So we took what we figured out f of x plus two is and then we added five and that's what g of x is. And then we are all done.