Verlet Integration

Поділитися
Вставка
  • Опубліковано 6 чер 2024
  • Here's a video describing a simple method to solve Newton's equations of motion. More info can be found here: www.algorithm-archive.org/cha...
    If you want to contribute, here's the github repo: github.com/algorithm-archivis...
    The music came from Josh Woodward (sped up 1.5 times):
    www.joshwoodward.com/
    Please feel free to follow me on Twitter:
    / leiosos
    Twitch (where I do all the simulations):
    / leioslabs
    or Github:
    github.com/leios
    Also, discord:
    / discord
    Also: Special thanks to butt4cak3 for the thumbnail!
  • Наука та технологія

КОМЕНТАРІ • 84

  • @methodiconion8523
    @methodiconion8523 6 років тому +173

    "no one cares about our B term because it's a JERK"
    You and you damned witticisms. I love the awesome pun!

    • @LeiosLabs
      @LeiosLabs  6 років тому +13

      Glad someone got it!

    • @RFC3514
      @RFC3514 5 років тому +12

      I find that kind of humour very derivative.

    • @Gplaysmc
      @Gplaysmc 5 років тому

      what does the B term stands for? I know the position formula but never saw a B occur in it

    • @rahulbhardwaj6896
      @rahulbhardwaj6896 5 років тому +1

      @@Gplaysmc third order derivative of displacement with respect to time, also known as 'jerk'.

    • @spyrgelispyy
      @spyrgelispyy 3 роки тому

      I was about to comment about that. Absolutely fabulous.

  • @T0C89
    @T0C89 6 років тому +101

    Great video! I am a computational physicist and want to mention one really cool and important reason we prefer Verlet over more complex integrators. The Verlet integrator is both symplectic and time reversal invariant. This means that if you run it and then run it in reverse, it will return the system to the original starting point. Because of this, the total energy of the simulated system will be conserved, which is important for physically realistic dynamics. So, even though another algorithm, like Runge-Kutta, has smaller local errors than Verlet, it does not conserve the total energy and will produce less physical Dynamics.
    Edit: I forgot to mention why being symplectic is important. Its because Newton's laws are symplectic and by using a symplectic integrator, we are guaranteed that our simulation will approach the true Newtonian solution. If you use an integrator that is time reversible but not symplectic, you will conserve an energy. But, that energy will not converge to the true energy as you make your time step smaller.

  • @crybirb
    @crybirb Рік тому +5

    Doing some game dev with cable physics this video proved to be INCREDIBLE, thanks for the concise and fast explanation. Wish you had content back when I was in University.

  • @karlramberg
    @karlramberg 6 років тому +46

    Small nitpick that your + and t looks very similar on the blackboard

    • @LeiosLabs
      @LeiosLabs  6 років тому +21

      yeah, I noticed that while editing. I'll try to do better in the future.

  • @LeiosLabs
    @LeiosLabs  6 років тому +8

    Thanks Buttercak3 for helping with the thumbnail!
    Here are the algorithms I am thinking about going through next:
    * Barnes-Hut (galaxy sim)
    * Mersenne Twister (prng)
    * Euclidean Algorithm (greatest common divisor)
    * Breadth-First Search (trees and stuff)
    We gotta start out simple, but it'll build quickly, I think.
    Thanks for watching and let me know what you think!

    • @jiegillet
      @jiegillet 6 років тому +1

      I'd love to code Barnes-Hut with Haskell :)

    • @LeiosLabs
      @LeiosLabs  6 років тому

      I added the vote to all the others on twitter. BFS still edges it out, so we'll go through that one first. It might be a good idea to do a tree algorithm first anyway.

  • @sirdorius361
    @sirdorius361 11 місяців тому

    Top level video and additional material. I've been doing some physics and orbital mechanics simulation in a game engine and this has helped a lot to clarify this method. Thanks!

  • @marcmarc172
    @marcmarc172 6 років тому +23

    I enjoyed learning about verlet integration; the video was concise and informative. My only criticism is that your 't' and '+' symbols are identical.
    edit: I just realized a previous comment already criticized this, making my criticism redundant

    • @LeiosLabs
      @LeiosLabs  6 років тому +4

      Yeah, I noticed that in the editing. I'll try to do better with it in the future.

    • @matejsedlacek3113
      @matejsedlacek3113 5 років тому +1

      Yr probably the nicest person on the internet

  • @adityabhardwaj459
    @adityabhardwaj459 2 роки тому

    IDK, but I always encounter great videos just 1 day before the exam :(
    Great work sir, thank you for helping us.

  • @sciencepit
    @sciencepit 3 роки тому +1

    I think It's just seconde order finite difference approximation of acceleration. I think this would give a good framework to study stability, accuracy and convergence and to compare the methodes (because euler and verlet would be just a subcase of finite differences approximation). It would also help implementing the methodes using matricies which is more efficient and systematic.

  • @squaremarco
    @squaremarco 5 років тому +17

    "No one likes the b term because it's a jerk..."
    oh you didn't LMAO

    • @LeiosLabs
      @LeiosLabs  5 років тому +5

      Finally someone gets it!

  • @JohnDlugosz
    @JohnDlugosz 6 років тому +2

    Re the comments on handwriting glyphs: In programming editors the modern trend is to use color highlighting editors that can automatically give variables, functions, and operators different colors.
    You are using white chalk on a black board, and your camera is locked down and stationary.
    So, you could colorize the final result when you are done writing, by using overlay rectangles that change white to whatever. Then apply that set of overlays to the entire segment -- it will have no effect on the blank board and you will have the foresight not to wear white cuffs.
    The result: magic colored chalk that syntax highlights as you write.

    • @LeiosLabs
      @LeiosLabs  6 років тому +1

      I actually tried something like this once, but the issue was that the "white" was not white enough from the chalk. I also tried using different color chalks, but they didn't show up on camera.
      I'll try to find some better ways to do it, though!

  • @SimonJackson13
    @SimonJackson13 3 роки тому +1

    integrate x^n times f(n) by parts to infinite series. obtain limit expression for when n = 0. Calculate high precision evaluations of the differentials of f at x, and the accelerate the series by S(S(S(n)) of say 9 terms. The result of the summation is one of a results for each application of S, and these can be considered to be another limit sum S(S(L(n))) and in turn S(L2(L(n))) providing the evaluation of the integral at one endpoint L3(L2(L(n))). As subtraction of endpoint integrals is the definite integral, the estimator is based on the precision of evaluation of the functional differentials of f.

  • @1234Daan4321
    @1234Daan4321 6 років тому +1

    Nice explaination. We also use this technique in theoretical chemistry :)

    • @LeiosLabs
      @LeiosLabs  6 років тому +1

      Yeah, it's used everywhere for when you need a rough approximation of kinematics.

  • @swetasinha4152
    @swetasinha4152 5 років тому

    In which programming language codes are written in algoruthm archive.?

  • @MarttyLovato
    @MarttyLovato 5 років тому

    best video of verlet i've seen and that i can understand, now i can do my tarea numérica (i think)

  • @brandonmcnally2975
    @brandonmcnally2975 5 років тому +1

    I saw "verlet intregration" on minecraft and I wasnt expecting this

  • @AJ-et3vf
    @AJ-et3vf Рік тому

    Awesome video! Thank!

  • @ragdamohammed5523
    @ragdamohammed5523 4 роки тому +1

    Okay where the b term comes from?? they miss mentioning that in my school

  • @BrandonSLockey
    @BrandonSLockey 3 роки тому

    what about verlet integration in the context of molecular dynamics simulations

  • @alexthi
    @alexthi Рік тому

    Nice article and video! As a PhD student who focuses on numerical integration techniques, I'd like to point out one misguided detail of your explanation : in the article you say that Verlet integration has an error in O(dt^4), whereas Velocity Verlet is in O(dt^2), so it's two orders worse. That's not quite the case: the consistency error of both methods has order 2. Sure enough, O(dt^4) and O(dt^2) are the error term in the equations you wrote ; but if you run both of them for a fixed duration, the results are of similar quality, with a final error in O(dt^2).
    How come Verlet converges only in O(dt^2)? Because it is only consistent at order 2. The simple way to isolate the consistency error is write the Verlet update as (x(t+dt)-2x(t)+x(t-dt))/dt^2 = a(t) + O(dt^2). You then see that as dt tends to zero, the left hand term converges to x'', with an error of O(dt^2). So this method is indeed an approximation of x''(t) = a(t), and we says it is "consistent at order 2".
    For Velocity Verlet it's a bit more complicated.
    In practice you must be very careful if you want to maintain order 2 consistency: dealing with collisions will almost surely drop the consistency order to 1 (so the error is in O(dt)).
    In fact, all the scripts in the article make an error in O(dt) due to the fact that they stop squarely on a time step when they detect the ball has touched the floor!
    Interpolating this time value from a simple linear approximation of the solution would drop this error to O(dt^2), which is the best we can hope for.
    In general, a higher order of consistency can be obtained easily using Runge-Kutta schemes.
    If you also want the method to be unconditionally stable you can use e.g. Gauss integration schemes, but things get much more involved quickly.

  • @emjizone
    @emjizone Рік тому +2

    0:15 Could you please give some references about these higher order terms that you will not use after a^2/2?

    • @AdrianBoyko
      @AdrianBoyko 9 місяців тому +1

      The equation you’re familiar with is specific to the case of uniform acceleration. Uniform acceleration is a safe assumption if one is considering situations that take place on or near the surface of a planet. But this video is about a situation where the distance from the bodies involved varies a great deal over time.

    • @emjizone
      @emjizone 9 місяців тому +1

      @@AdrianBoyko This is not what I am familiar with. I am familiar with infinite number of higher derivation terms.
      I'm now confident I get what you mean, though. Thanks.

  • @matthewgiallourakis7645
    @matthewgiallourakis7645 6 років тому +3

    Here's a very pythonic (3.6 only) implementation that tests the time of a 5 meter drop and the distance of a 1 second drop.
    def verlet_drop(pos, acc, dt, end_time=0, end_pos=0):
    time, prev_pos = 0, 0
    acc_factor = acc*dt*dt
    running = lambda: (time < end_time if end_time!=0 else pos

  • @lolatomroflsinnlos
    @lolatomroflsinnlos 6 років тому +4

    Using Java:
    //Given Starting conditions
    int initialPosition = 5; //in meters above ground
    double gravitationalAcceleration = 9.81; //Gravitational acceleration in m/s²
    //Wanted
    double timeToHitTheGround; //Time to hit the ground in seconds
    //Calculate time to hit the ground
    timeToHitTheGround = Math.sqrt( 2*initialPosition/gravitationalAcceleration);
    //Print solution
    System.out.println("Time to hit the ground: ~ "+(int) timeToHitTheGround+"s"
    +"
    ["+timeToHitTheGround+" seconds]");
    This prints out:
    Time to hit the ground: ~ 1s
    [1.0096375546923044 seconds]

    • @LeiosLabs
      @LeiosLabs  6 років тому

      Great! Thanks for the submission!

    • @LeiosLabs
      @LeiosLabs  6 років тому +1

      wait, I should have specified that the submissions should be using the verlet method mentioned in the video... I added an example in c++ to the archive: leios.gitbooks.io/algorithm-archive/content/chapters/computational_physics/verlet.html
      I'll be more clear in the future. Thanks again!

    • @lolatomroflsinnlos
      @lolatomroflsinnlos 6 років тому +3

      It pretty much works just by copying your code, with a bit of adjusting:
      static void verlet(double pos, double acc, double dt){
      // Note that we are using a temp variable for the previous position
      double prev_pos, temp_pos, time;
      prev_pos = pos;
      time = 0;
      while (pos > 0){
      time += dt;
      temp_pos = pos;
      pos = pos*2 - prev_pos + acc * dt * dt;
      prev_pos = temp_pos;
      }
      System.out.println(time);
      }
      // Simple function for stormer-verlet
      static void stormer_verlet(double pos, double acc, double dt){
      // Note that we are using a temp variable for the previous position
      double prev_pos, temp_pos, time, vel;
      prev_pos = pos;
      vel = 0;
      time = 0;
      while (pos > 0){
      time += dt;
      temp_pos = pos;
      pos = pos*2 - prev_pos + acc * dt * dt;
      prev_pos = temp_pos;
      // The acceleration is constant, so the velocity is straightforward
      vel += acc*dt;
      }
      System.out.println(time);
      }
      // Simple function for velocity-verlet
      static void velocity_verlet(double pos, double acc, double dt){
      // Note that we are using a temp variable for the previous position
      double time, vel;
      vel = 0;
      time = 0;
      while (pos > 0){
      time += dt;
      pos += vel*dt + 0.5*acc * dt * dt;
      vel += acc*dt;
      }
      System.out.println(time);
      }
      public static void main(String[] args) {
      verlet(5.0, -10, 0.01);
      stormer_verlet(5.0, -10, 0.01);
      velocity_verlet(5.0, -10, 0.01);
      }
      But snake_case should be changed to camelCase I guess?

    • @LeiosLabs
      @LeiosLabs  6 років тому +1

      Yeah, we can change it to camel case. Thanks again!

  • @Himanshu_5_
    @Himanshu_5_ 5 років тому

    what about potential energy ?

  • @2wheels2
    @2wheels2 5 років тому

    What program did you use?

    • @LeiosLabs
      @LeiosLabs  5 років тому

      We wrote it ourselves in OpenGL or Cairo.

  • @mrembeh1848
    @mrembeh1848 4 роки тому

    def duration(height): if height == 5: return 1

  • @peaceandlove5855
    @peaceandlove5855 6 років тому

    please the website (or link) at 2:22

    • @LeiosLabs
      @LeiosLabs  6 років тому

      In the description: www.algorithm-archive.org/chapters/physics_solvers/verlet/verlet.html

  • @Imboredwithmylife
    @Imboredwithmylife Рік тому

    Mom can we have v sauce?
    No we have v sauce at home
    V sauce at home:

  • @Magnasium038
    @Magnasium038 5 років тому +2

    Huh. So this channel is kind of a Minute Algorithms

  • @columbus8myhw
    @columbus8myhw 6 років тому +5

    Dude, your 't's and '+'s look identical

    • @columbus8myhw
      @columbus8myhw 6 років тому

      Draw the horizontal bar on the 't' first and draw the vertical line with a curve on the bottom

  • @yoosufahmadh3945
    @yoosufahmadh3945 3 роки тому

    Thanks

  • @spencertaylor6910
    @spencertaylor6910 6 років тому +10

    No one cares about your b ten because it's a jerk! That was hilarious!

    • @LeiosLabs
      @LeiosLabs  6 років тому +1

      Finally someone gets it!

    • @RFC3514
      @RFC3514 5 років тому

      Well, "finally" seems a bit excessive; according to the post above this one, someone got it 6 months ago. :P

  • @retired5548
    @retired5548 6 років тому

    can someone direct me to the full kinematic equation, please?

    • @LeiosLabs
      @LeiosLabs  6 років тому

      I wrote it down with an additional term. For the most part, it is a Taylor series expansion about a point.

    • @retired5548
      @retired5548 5 років тому

      oh yeah. why didn't i think about that? thank you

  • @Arnaz87
    @Arnaz87 6 років тому +2

    what is b?

    • @LeiosLabs
      @LeiosLabs  6 років тому +4

      Position over time is velocity. Velocity over time is acceleration. Acceleration over time is b, the "jerk" term.

    • @Arnaz87
      @Arnaz87 6 років тому +2

      Damn, that was fast, thanks! Bingewatching your videos and i'm loving them!

    • @LeiosLabs
      @LeiosLabs  6 років тому

      I'm glad you like the content! I do my best to respond to all comments as fast as I can.

  • @wittleliener
    @wittleliener Рік тому

    Great video but your similarity to Ramsay Bolton is frightening :D

  • @brandonmcnally2975
    @brandonmcnally2975 5 років тому

    I think I'm in the wrong place

  • @victherocker
    @victherocker 5 років тому

    Is the educational level of this stuff too high for a just-graduated-from-highschool student like me? or am I just stupid?

    • @LeiosLabs
      @LeiosLabs  5 років тому

      You are definitely not too stupid.

  • @STANNco
    @STANNco 2 роки тому +1

    "because of how straight forward this is"
    hold up. That wasn't straight forward at all, I don't know what half of these terms mean so I didn't learn anything

  • @yellooo3107
    @yellooo3107 3 роки тому

    b-b-beginner??

  • @jiegillet
    @jiegillet 6 років тому +2

    This one is hoping you know how to include s in a gitbook :)
    With Scratch: scratch.mit.edu/projects/173039394/

    • @jiegillet
      @jiegillet 6 років тому +1

      I also had fun with Haskell:
      github.com/jiegillet/Arcane-Algorithm-Archive/tree/master/Verlet

    • @LeiosLabs
      @LeiosLabs  6 років тому +1

      nerd

  • @ChannelKucing294
    @ChannelKucing294 3 роки тому

    meow

  • @brandonmcnally2975
    @brandonmcnally2975 5 років тому

    😦