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

Equation for simple harmonic oscillators

David explains the equation that represents the motion of a simple harmonic oscillator and solves an example problem. Created by David SantoPietro.

Want to join the conversation?

  • spunky sam blue style avatar for user Eesh Starryn
    Shouldn't the cosine function at 1 point compress and reach zero? I had his query because I thought that the block eventually reaches the equilibrium position.. It doesn't really have this constant oscillation between the maximum value and minimum value. Also, why has he used particularly he cosine function?
    (18 votes)
    Default Khan Academy avatar avatar for user
    • male robot hal style avatar for user Jan Gregrowicz
      Well, this is the idealized model, where the friction is neglected, so we assume that the block oscillates forever. As you have written it does not REALLY have this constant oscillation, but in this case it is "unreally".
      He used cosine function just as an example. He assumed that at the time=0, the block is at the maximum value, but this was just an arbitrary assumption.
      (32 votes)
  • blobby green style avatar for user Nahapetyan.GorY9
    What if the graph doesn't start at a miximum, minimum or 0?
    (10 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user footballsamuel77
      actually that situation is highly impossible....'cause in that case, the law of conservation of energy would not be valid anymore. just think about it.......if it started at 0.2 meters from the mean position, the amplitude keeps decreasing.....it can never keep increasing just like that......if it was pulled to 0.2 meters then the next time it may stretch upto only 0.18 meters probably. Even the example shown in the video is only hypothetical....no oscillation keeps going on on its own.......it stops at some time. So your given condition is actually never possible, even in a force free field.
      (11 votes)
  • male robot hal style avatar for user Ammar
    What does this function output again?
    (5 votes)
    Default Khan Academy avatar avatar for user
    • purple pi purple style avatar for user APDahlen
      Hello Ammar,

      These oscillators can be tricky. We start with a physical movement such as a mass moving up and down on the end of a spring. We finish with trigonometry. At first this is very nonintuitive but I encourage you to keep working. This modeling of oscillators based on trigonometry is a very powerful technique.

      Regards,

      APD
      (7 votes)
  • starky seed style avatar for user hamadullah
    Will the spring vibrate infinitely in space or in vacumm
    (3 votes)
    Default Khan Academy avatar avatar for user
  • spunky sam blue style avatar for user soap
    Sine and Cosine are just shifted versions of each other. Does it really matter which trig function I use ?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Nanbragan
    Why don't you account for the phase angle? In my textbook it has the equation as x = A cos ( wt + (greek letter phi)). It says Greek letter phi = phase angle. Thank you
    (3 votes)
    Default Khan Academy avatar avatar for user
  • eggleston blue style avatar for user DigontoB.
    if the formula for cosine is: x(t)= A cos(wt), then what will be there for the sine?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Jacob Berg
    Let me preface this by saying that this is a question.

    Where f(x) = A(cos(Bt - h)) + k, the B value, or horizontal stretch/compression factor, in order to equal 6 seconds, must be (π/3).
    The standard oscillatory trigonometric equation has a period of (2π). The equation to determine the period of an oscillatory trigonometric equation is [ P = (2π) / |B| ].
    Setting P = 6, we get:
    [ P = 6 = (2π) / |B| ]
    [ ( |B| / (2π) ) = ( 1 / 6 ) ]
    [ |B| = ( (2π) / 6 ) ]
    { |B| = ( π / 3) }

    Why is 6 seconds put in the video as the absolute value of the horizontal stretch/compression factor when that is not the case? The next example appears to have an incorrect period as well.
    (2 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Kim
    if the function starts from x=0, do we need replace cosine to sine so it would be like x(t)=Asin(wt)?
    in my course book, the equation is x(t)=Asin(wt+ϕ) ? is there any difference between this equation and x(t)=Acos(wt)?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • stelly green style avatar for user The #1 Pokemon Proponent
      cos(wt) = sin(wt+pi/2). This is what we call a phase shift of pi/2. Basically, a cosine wave is a sine wave pushed forward by pi/2 radians. The best way to a SH oscillator is either Asin(wt+phi) or Acos(wt+mu). To determine the phase shift, (phi/mu) we need boundary conditions. For example, we need to know what the speed of the oscillator is at t=0. Using such a condition gives us the phase shift and allows us to fully understand the wave's motion.
      (5 votes)
  • primosaur seedling style avatar for user Alan Jarvis
    I understand that this is intended to be an simple overview, but I think you are gloosing over some important assumptions here.
    The first is that this "spring" is an ideal one.
    The 2nd is that it's only an ASSUMPTION that a sin (or cos) function fits as a POSSIBLE solution of the differential equation. It's only an ASSUMPTION. We don't KNOW that.

    This is important, because the explanation jumps to using a cos function without explaining WHY it was chosen.
    (2 votes)
    Default Khan Academy avatar avatar for user
    • male robot hal style avatar for user Charles LaCour
      If this was a standalone video then there may need to be more discussion on springs and why trig functions are used but with this video being part of Unit 8 and there being a section on springs in Unit 5 this is building off that and doesn't need to be covered again.
      (3 votes)

Video transcript

- [Instructor] Alright, so we saw that you could represent the motion of a simple harmonic oscillator on a horizontal position graph and it looked kinda cool. It looks something like this. And the amplitude of that motion, the maximum displacement from equilibrium on this graph was just represented by the maximum displacement from equilibrium, it looked like this. And the period, which was the time it took for this entire process to reset, capital T, is the period, is the time it takes to reset was the time it takes to reset, which would be from peak to peak or from trough to trough or from any point to any analogous point on that cycle, this was the period T. And so, with a graph that's a sine or a cosine, you could represent any motion you want. So, if you had some oscillator that had a larger amplitude, you can imagine just stretching this thing vertically, the period would stay the same, but you could stretch out the amplitude. Or, if you had something with a larger period, you can imagine stretching it out horizontally and leaving the amplitude the same, or stretch it both ways to represent any oscillator you want, which is kinda cool. However, a lot of times you also need the equation, in other words, you might wanna know what equation would describe this graph right here. What equation would represent this graph here? First of all, what do I even mean by like, the equation for this graph? What I mean is that this graph's representing the horizontal position, X, which is how far the mass has been displaced this way from equilibrium, as a function of time. So, we want a function that will be, alright, what is the value of the position of this mass as a function of time? So, what would this equation be? Gonna be a function, in other words, you're gonna feed this function anytime you want, and the function's gonna give you, it's gonna spit out a value for the position, and that should represent whatever position this graph is representing, where the mass is at, because the graph should agree with what this function's gonna tell us. And this function would tell us where the mass is at any given moment. So, what would this look like? Now, we saw, like, this is a sine or a cosine, right? So, this is either a sine or a cosine. That's the first choice. Do we wanna pick sine or cosine? And what I always do, is I just look at the beginning and I say, alright, in a T equals zero, this one's starting at a maximum. So, I wanna use cosine because cosine starts at a maximum and by starting at a maximum, I mean, think about it, for a cosine of zero, if you remember your trig functions, cosine of zero is equal to one. And so, because this is as big as cosine ever gets. Sine and cosine can only ever get as big as one. This thing's starting at a maximum. So, cosine starts at a maximum at T equals zero. This function here starts at a maximum at T equals zero. I'm gonna wanna use cosine but I'm gonna have to add a few elements in here. Just cosine alone isn't gonna do it for me, because cosine only gets as big as one. This thing has to get as big as A, whatever A is, this thing has to get that big. So, in other words, my simple harmonic oscillators aren't always gonna have an amplitude of one, so I need some variable in here that will represent what the amplitude is for that given simple harmonic oscillator. Let me make this less abstract. Let me just say, let's say we happened to pull this thing back 20 centimeters for .2 meters. So, let's say our amplitude for a particular simple harmonic oscillator happened to be .2 meters, that would mean that this here, I can represent this here with .2 meters, this doesn't even make it to one. So, if I just left this as cosine, that would say this thing's gonna get as big as one at some point in time and that's a lie. This thing only gets as big as .2, so it's easy though. You might realize, if you clever, we'll just multiply the front of this thing by the amplitude, whatever the amplitude is multiplied, 'cause then one times amplitude means that this X only gets as big as the amplitude, which is exactly what I want. I want this thing to be as big as whatever the amplitude is of the motion. And then there's one more piece, you can't, you might be, like, alright, we're done, I'm just gonna stick cosine of T in here, that's not gonna work. We do want this to be a function of time, right? We wanna be able to plug in a time and have this function spit out what is the value of the position of the graph, and that would represent where is it. So, is it at .2, is it at .1, is it at .045, or something like that? That's what this function's supposed to do. But just plugging in T here, just having T alone, isn't gonna be good because that would mean, look at, a cosine of zero, we know cosine's one. When does cosine get back to one? That's gonna be when the inside, the argument in here, is two pi. So, we're gonna be using radians. You could use degrees if you wanted to, but most physicists and professors and teachers are gonna be using radians for this case. So, a cosine of two pi would again be one because that's when, if you remember your unit circle, that's when this function for cosine has gone around one whole time and it gets back where it started, right? So, if something rotates through an angle of two pi, you've reset the whole thing and that process has reset. But that would mean this function resets every two pi seconds, right? 'Cause at T equals zero, the function was one, and then at T equals two pi, the function's one again. That would mean the period for cosine of T is two pi but our period isn't necessarily two pi, right? Unless you got a really special case, the period is whatever the period is. Let's say it happened to be, let's say our period happened to be like six seconds for this particular case. So, if this was six seconds, we would not want a function that resets after two pi seconds, we need a function that resets after, for this case, six seconds. So, how do we do that? Well, we have to not just have T in here. We saw that if we just have T, the period is always two pi, 'cause that's when cosine of T resets. How would we do this? Well, we're gonna be clever. And if you're really clever you realize, alright, I'm just gonna add a little variable in here. I'm just gonna a little variable, boom, omega and then multiply that by T, and then I can tune this omega however I want, right? If I can make omega big or small, I can make the period of this function whatever I want. And if you're curious, you might be like, wait a minute, omega, we've used that before, and you'd be right. Omega we have used before. That was the angular velocity and remember, angular velocity was delta theta over delta T, the amount of change in angle over the amount of change in time, which you might think isn't relevant here 'cause this mass is just going back and forth. This mass isn't actually rotating in a circle. However, you can represent repeating processes, cyclic processes, processes that go through a cycle on a unit circle. So, in other words, let's say you start right here, right? So, at T equals zero, you start, we pulled this mass back and then we let go. So, we start right there. That would be right here on this unit circle and then it flies through the equilibrium point, that would be through a quarter of a cycle, that means it would have made it to right here. And then it makes its way over to this edge, fully compresses this thing that would be over to here, that would be through half a cycle, and that would come back through, let me find another dark color, it would come back through the equilibrium point and that would be down here. And then we would get back to the initial point and that would be one whole cycle. So, you can see how we can represent cyclic processes on a unit circle and that's how this makes sense. That might seem abstract but it's really useful 'cause watch what we could do. Naively you might think, alright, how would we even define this? Well, one cycle on a unit circle is two pi radians, right? If we're using radians, then one cycle would be two pi 'cause two pi is once around the circle. And how long does that take? Well, I know for a simple harmonic oscillator, we defined the period to be the time it takes for one whole cycle. So, we'd have two pi over the period and this is what you would plug in down here. So, it turns out this does work. So, even naively, just using our ideas of angular velocity, plugging in two pi over the period, will give us a function that resets exactly when we want it to. And you might not be convinced. And if that doesn't make sense, I don't blame ya. I might be confused too. So, let me show you what I mean. In other words, we take this function, instead of writing omega, we can just do this. We can just be like, alright, forget this, taken this, omega is the angular velocity, sometimes it's called the angular frequency, in this case, so people use different terminologies. You'll hear it as angular velocity or angular frequency. If you take this angular velocity or angular frequency, we just smack that right in here. So, we just put that in there for omega, and then multiply by T. Watch what happens, this is beautiful. So, if we take this, now it's gonna work. So, we multiply by T. T is our variable. So, little t is our variable, two pi's the constant, the period capital T is also a constant, it'll be different for different harmonic oscillators. But for a given harmonic oscillator, capital T the period is a constant. So, watch what happens now. At T equals zero, this whole inside becomes zero. So, let's say I plug in T equals zero. We get to plug in little t whatever we want. That is our variable, so if I plug in little t equals zero, cosine of zero gives me one. But now what happens? If I plug in t equals, alright, after one whole process, right, after one whole cycle, it's gone through one whole period, so if I plug in little t as capital T, the period. Look what happens. This capital T cancels with that capital T and you just get two pi in here and the cosine of two pi is also one. That means this thing goes through a cycle every capital T, period. That's what we wanted. We didn't want something that always had to have two pi as the period. Now we've got a function that we can plug in whatever our period is down here. That way, whenever this little t makes it to the period, capital T, this whole argument in here becomes two pi and the cosine resets itself and you get a graph or a function that will give you a graph that resets every period, which is exactly what we wanted. So, in other words, to make this less abstract, let's take this thing here, for this particular function here, for this particular choice of amplitude and period, we could say that the graph that's representing this, so the function that would represent this here, instead of amplitude, we'd plug in .2. So, 0.2, let me try to fit it in here, 0.2, I don't wanna put the units down here, meters times cosine, remember, we wanted cosine 'cause it starts at a maximum and this graph started at a maximum. If it started down here and went up, I'd use sine because sine starts at zero. But this one started at a maximum. And I have two pi over the period, I can't just leave that as period T, that's a little bit vague, I'd put in my actual period and we said that the actual period for this mass on a spring was six seconds. And then little t, a lot of times people get confused, they're like, alright, what do I plug in for little t? You don't, typically, like, if you just want the function for the position as a function of time, you leave little t as the variable. That's the variable that you have sitting here, right? If I wanted to know what is the value of the position of this mass at nine seconds, I would plug in nine seconds. I would calculate this function with the nine seconds in there, that would be the position at nine seconds. Or, if I wanted the position at 12.25 seconds, I'd plug in 12.25 seconds for our little t time, calculate this function, plug it into the calculator in other words and that would give me the position at 12.25 seconds. That's what this function can do for you. That's how it can represent the motion of a simple harmonic oscillator. And now you might be like, dude, that took a long time. Do they all take that long? No, once you get good at this, it's really easy. Watch, let me get rid of all that. Let's say you got this problem on a test or a quiz or whatever, on homework, and it was like, hey, make an equation that describes this simple harmonic oscillator. It's easy. First thing you do, do I want to use sine or cosine? So, you might be like, oh, crud, it doesn't start at a maximum and it doesn't even start at zero, sine would start there. It starts down here, but that's okay. It starts at a minimum. So, we're still gonna use cosine. So, we're gonna say that X as a function of time is gonna be, well, what's the amplitude? The amplitude here is three meters. So, three meters is our amplitude because that's the maximum displacement from equilibrium, so I'm gonna have three meters out front and then I'm gonna do cosine because it starts at an extreme value, like either a maximum or a minimum value. Cosine of, and then I need two pi over the period. What is my period? I look at my graph and I ask, how long does it take to reset? So, started down here at a minimum, when does it get back to a minimum? That took four seconds. So, four seconds would be the period, so it'd be two pi over four seconds and then little t, what do I plug in for little t? I don't. This is the variable that sits there and waits for me to plug in whatever I want. So, that's my variable little t that X is a function of. But I'm not done. This would be a graph that starts up here and goes down like that. This graph starts down here but that's easy. You just multiply by a negative sine out front and you've turned your cosine into negative cosine and negative cosine starts down here. So, note our amplitude is still three. If the question asked, what is the amplitude? The amplitude is the magnitude of the displacement, maximum displacement, so that's still positive three meters, even though it started down here, but you could just include an extra negative out front that essentially goes along with the cosine. That would give you negative cosine and there you have it, that would be your function. So, keep in mind, it's good to remember, if you start up here, you're gonna wanna use cosine. If you start down here, you gonna wanna to use negative cosine. If you start right here, you're gonna wanna use sine. If you start here and go up, that's gonna be sine. And if you start here and go down, that's gonna be negative sine. That's what those functions look like. So, recapping, you could use this equation to represent the motion of a simple harmonic oscillator which is always gonna be plus or minus the amplitude, times either sine or cosine of two pi over the period times the time. This two pi over the period is representing the angular frequency or angular velocity and you would choose positive cosine if you started at a max, negative cosine if you started at a min. Positive sine if you start at zero or equilibrium and go up. Negative sine if you start at equilibrium and go down.