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

Transforming sinusoidal graphs: vertical & horizontal stretches

Sal graphs y=-2.5*cos(1/3*x) by considering it as a vertical stretch and reflection, and a horizontal stretch, of y=cos(x). Created by Sal Khan.

Want to join the conversation?

  • leaf blue style avatar for user Kathi
    Does -sin(x)=sin(-x) ?
    (80 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user CC
    is there a video that includes horizontal shift, or the "c" value in y=d+a(sin)(b(x-c))?
    if yes, could someone please direct me towards it? and if not, how do you find c when only given a maximum and minimum for the function? i have my final tomorrow and i am still baffled! thanks so much!
    (17 votes)
    Default Khan Academy avatar avatar for user
    • purple pi purple style avatar for user doctorfoxphd
      Sorry we missed your final. Horizontal shift for any function is the amount in the x direction that a function shifts when c ≠ 0. Horizontal shift can be counter-intuitive (seems to go the wrong direction to some people), so before an exam (next time) it is best to plug in a few values and compare the shifted value with the parent function. Pick an obvious marker point, such as where the maximum is on the unshifted function and where the function equals zero. Those are the easiest points to compare. A graphing calculator works well for this, especially if you use one of the ones on line that will give you different colors. You can learn a lot very quickly. If all else fails, graph a few points with pencil and paper. It is slower, but it also works. Once you become familiar with how it works it will be easier to work with the calculations.

      Phase shift c is best discovered by pattern matching if you are given an equation, or by examining values when sin equals a significant point such as zero or maximum or a minimum. You cannot solve for phase shift given ONLY the maximum and minimum values, so I think you may also be given the points where those maximum and minimum values occur. Given that it is easy (well, OK, it is still work) to turn into a detective and figure out phase and interval, and figure out how the function fits over its interval. One phase WILL begin at x=c.
      (9 votes)
  • male robot hal style avatar for user Arturo Aganza
    If Sin is equal to 'y' values and Cos is equal to 'x' values in the unit circle, why this graph have 'y' values if he is using a cos function??
    (12 votes)
    Default Khan Academy avatar avatar for user
  • spunky sam blue style avatar for user Chunmun
    At , why only 3π is used and why not other angles ?
    (4 votes)
    Default Khan Academy avatar avatar for user
    • purple pi purple style avatar for user doctorfoxphd
      Well, it was just the most reasonable and efficient angle to use. Easy for us to say! Here's why:
      The shape of the cosine function is very predictable. If you start looking at the beginning of the period, and it is at a maximum there, then at the end of the period, which we just calculated is 6 pi, it will have come back to the maximum value, by definition. We know that the point exactly in between the ends of the curve at its two maximums will be the minimum point. So, Sal knew exactly where the midpoint would be which is 6/2 pi or 3 pi, and the curve of cosine at the midpoint of the period will be at a minimum if it is at a maximum at the ends of the period. If you have a lot of time, you can plot values of the function at other angles to see what is happening. In fact that is very helpful for understanding the behavior of functions.

      Color graphing calculators are great for comparing lots of trig functions quickly to see what happens with amplitudes and periods and maxima and minima. Be sure to graph on a trig scale, though, and give yourself just enough vertical scale to see the curves. Otherwise the graphs are tough to see. A trig function is very happy with vertical scales of small numbers.
      (11 votes)
  • leafers seedling style avatar for user Nathaniel Garcia Tascione
    Hello, so, for the last two videos, they made perfect sense and helped out a lot to understand how to graph the equation. although, I found myself really lost when it came to the practice problems after the videos. I don't feel like these videos prepared me enough for the practices because the problems in the practices were much more complicated, to me that is, and I was wondering if you could include a video about how to solve a problem that has a constant after the coefficient of x
    (2 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user InnocentRealist
      "x" here is theta on the unit circle. On the unit circle if we know x than we can get +-y and if we know y we can get +-x. Theta is defined as the angle with sine y/r (= y), or with cosine x/r (= x).

      In these graphs of sine functions, x stands for theta on the unit circle and is the independent variable.
      When you graph, say, "y = sin(x+10)", you are plotting the value of "sin(x+10 radians)" at the x coordinate "x radians". Thus, you are getting y values from 10 radians to the right of where you are on the x axis (y=sin(13 radians) for x = 3 radians, y=sin(19 radians) for x=9 radians, y=sin(5 radians) for x= -5 radians, etc.), which shifts the graph to the left by 10 radians.
      When you graph "sin(x-10)" you are plotting "sin(x-10 radians)" at the x coordinate "x radians", so you're getting y values using an x that is 10 radians to the left of where you are on the x axis (y=sin(-7 radians) for x = 3 radians, y = sin(-1 radian) for x = 9 radians, y = sin(-15 radians) for x = -5 radians, etc.), which shifts the graph to the right 10 radians.
      (8 votes)
  • leafers ultimate style avatar for user Anatoly Rozhkov
    As far as I understand phase shift works like this:
    cos(2x-pi/3)
    where the phase part is:
    x-pi/3 = 0
    x = pi/3
    I thought this means that the whole function shifts to the right by pi/3, but I couldn't graph it in the exercise, so I pressed on the hint option, and it said that x-pi/3 is equivalent to pi.
    I don't see how these two can be equivalent. Could someone explain this to me?
    (4 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user cossine
      There two transformations going on, the horizontal stretch and the phase shift.

      To stretch a function horizontally by factor of n the transformation is just f(x/n).

      So let f(x) = cos(x)

      => f(x/(1/2)) = cos(x /(1/2) ) = cos(2x)

      So the horizontal stretch is by factor of 1/2.

      Since the horizontal stretch is affecting the phase shift pi/3 the actual phase shift is pi/6 as the horizontal sretch is 1/2.

      cos(2x-pi/3) = cos(2(x-pi/6))
      (2 votes)
  • marcimus pink style avatar for user Miriam Smith
    How do I find the period of any given function?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • piceratops ultimate style avatar for user kwonines
    None of these videos seem to be answering my question: in the formula a*sin(bx + c) + d, a is the amplitude, b determines the period, and d equals the midline. What does c do?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • male robot hal style avatar for user LuisPK435
    I'm having trouble finding a video on phase shift in sinusoidal functions within the lesson plan, and am trying to piece it together via the practical exercises... but its been very time consuming! Does a video on phase shift for sinusoidal functions exist?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • leaf green style avatar for user Bryan Alexander Blanco
    How would you graph a trig function that has a constant in place of the y-value? In other words, if you take the graph of y = tan(x), and input a 3 for the y-value, what would the graph of 3 = tan(x) be equal to? My gut tells me it should be a horizontal line at y = 3, but my gut isn't that smart! Any ideas?
    (2 votes)
    Default Khan Academy avatar avatar for user

Video transcript

We are asked to graph the function y is equal to negative 2.5 cosine of 1/3 x on the interval, 0 to 6 pi, including the endpoints. So let me do my best attempt at graphing that. And to start off, I'm going to graph with the simplest function, or the simplest version of this, or the root of this, which is just cosine of x. So let me just graph, and eventually you can kind of-- let me just graph cosine of x. So that's my y-axis. And I want to have some space here so I can eventually graph this entire thing. So let's say that this is negative 1, this is negative 2. This is positive 1, this is positive 2. And let's say that this right over here is 2 pi. And then of course that could be pi right over there. Now, the first thing I'm going to do-- let me copy this because I could use it later to graph the whole thing. So let's start off. So I'm just going to graph y is equal to cosine of x. So when x is equal to 0-- and I'm just going to do it between the interval 0 and 2 pi. Obvious it's a periodic function, it'll keep going in the negative and the positive directions. So what happens when x is equal to 0? What is cosine of x? Well cosine of 0 is 1. What about when x is equal to pi? What is cosine of pi? Well cosine of pi is negative 1. And then what's cosine of 2 pi? Well that's 1 again. We get back-- we've completed a period, or we've completed an entire cycle. And 2 pi is the period of cosine of x. So this is one cycle right over here. I could keep going if I wanted to, but the whole point, I just wanted to graph this one cycle between 0 and 2 pi. Now what I want to think about is, what happens to this graph? Instead of graphing y equals cosine of x-- let me draw some graph paper again. Instead of drawing y is equal to cosine of x, I'm going to draw y is equal to cosine of 1/3 x. So the only difference between that and that is now I'm multiplying the x by 1/3. What's going to happen to the graph over here? How is this going to change instead of being an x, if it's a 1/3 x? What's going to happen over here? And now I'm going to do it over the entire interval between zero and six pi. So let me just make sure I have enough space. So that's 3 pi, 4 pi, 5 pi, and 6 pi. What's going to happen to this graph? Well, there's a couple of ways to think about it. The easiest might just be to say, well to complete an entire cycle, we're going to go 1/3 as fast. Or we're going to go three times slower. Or if you just want to think about the period here, what's the period of cosine of 1/3 x? Well the period is going to be 2 pi divided by the absolute value of this coefficient right over here. So it's the absolute value of 1/3, which is just 1/3. So the period is 2 pi over 1/3, which is the same thing as 2 pi times 3, which is 6 pi. Which gels with the intuition. That's going to take three times as much time to get whatever we input into the cosine function to get back to 2 pi. Because whatever we take x, we're taking 1/3 of it. So to get to 2 pi, you can't just have x equals 2 pi. x now has to equal 6 pi to get 2 pi inputted into the cosine function. So the period is now 6 pi. At x is equal to 0, 1/3 times 0 is 0, and the cosine of 0 is 1. When x is equal to 6 pi, you have 6 pi divided by 3 is 2 pi. Cosine of 2 pi is equal to 1. And if you want to go in between, over here to go in between, we tried pi. But over here, we could try 3 pi. When x is 3 pi, you have cosine of 1/3 of 3 pi, that's cosine of pi. Cosine of pi is negative 1. So when x is equal to 3 pi, we have cosine of 1/3 times 3 pi is negative 1. So it's going to look something like this. Trying my best attempt. to draw it. So it's going to look something like this. So you see, to go from y equals cosine of x to y equals cosine of 1/3 x, it essentially stretched out to this function by a factor of 3. You can see this period is three times longer. The period here was 2 pi. All right, well there's only one more transformation we need in order to get to the function that they're asking us about. We just have to, instead of having a cosine of 1/3 x, we just have to negative 2.5 cosine of 1/3 x. So let's try to draw that. So let me put my axis here again. And let me label it. So that's 2 pi, 3 pi, 4 pi, 5 pi, and 6 pi. And our goal now is to draw the graph of y is equal to-- and we're just doing it over between 0 and 6 pi here. We only did it between 0 and 2 pi here. Obviously they're all periodic, they all keep going on and on. But now we want to graph y is equal to negative 2.5 times cosine of 1/3 x. So given this change, we're now multiplying by negative 2.5, what is going to be-- well actually, let's think about a few things. What was the amplitude in the first two graphs right over here? Well there's two ways to think about it. You could say the amplitude is half the difference between the minimum and the maximum points. In either of these case, the minimum is negative 1, maximum is 1. The difference is 2, half of that is 1. Or you could just say it's the absolute value of the coefficient here, which is implicitly a 1. And the absolute value of 1 is, once again, 1. What's going to be the amplitude for this thing right over here? Well the amplitude is going to be the absolute value of what's multiplying the cosine function. So the amplitude in this case, do it in green, the amplitude is going to be equal to the absolute value of negative 2.5, which is equal to 2.5. So given that, how is multiplying by negative 2.5 going to transform this graph right over here? Well let's think about it. If it was multiplying by just a positive 2.5, you would stretch it out. At each point it would go up by a factor of 2 and 1/2. But it's a negative 2.5, so at each point, you're going to stretch it out and then you're going to flip it over the x-axis. So let's do that. So when x was 0, you got 1 in this case. But now we're going to multiply that by negative 2.5, which means you're going to get to negative 2.5. So let me draw negative 2.5 right over there. So that's negative 2.5. That'd be negative-- let me make it clear. This would be negative 3 right over here, this would be positive 3. So that number right over there is negative 2.5. And let me draw a dotted line there. It could serve to be useful. Now when cosine of 1/3 x is 0, it doesn't matter what you multiply it by, you're still going to get 0 right over here. Now, when cosine of 1/3 x was negative 1, which was the case when x is equal to 3 pi, what's going to happen over here? Well cosine of 1/3 x, we see, is negative 1. Negative 1 times negative 2.5 is positive 2.5. So we're going to get to positive 2.5, which is right-- let me draw a dotted line over here. We're going to get to positive 2.5, which is right over there. And then when cosine of 1/3 x is equal to 0, doesn't matter what we multiply it by, we get to 0. And then finally, when x is at 6 pi, cosine of 1/3 x is equal to 1. What's that going to be when you multiply it by negative 2.5? Well it's going to be negative 2.5. So we're going to get back over here. So we're ready to draw our graph. It looks something-- let me do that in magenta color since that's what the color I wrote this in. It will look like this. I can draw it as a solid line. So it will look like that. So you saw what happened. By putting this 1/3 here, it stretched out the graph. It increased the period by a factor of 3. And then multiplying it by negative 2.5-- if you just multiply it by 2.5, you would just multiply that out a little bit. But now it's a negative, so not only do you increase the amplitude, but you flip it over. So it is, indeed, the case that the amplitude here is 2.5. We vary 2.5 from our middle position. Or you could say that the difference between the minimum and the maximum is 5, so half of that is 2.5. But it isn't just multiplying this graph by 2.5. If you multiply this graph by 2.5, you'd get something-- let me be a little neater. You would get something that looked something like that. But because we had a negative, we had to flip it over the x-axis. And we got this here. So this amplitude is 2.5, but it's a flipped over version of this graph.