Coding Challenge #93: Double Pendulum

Поділитися
Вставка
  • Опубліковано 27 тра 2024
  • In this coding challenge, I create a double pendulum simulation in Processing. Code: thecodingtrain.com/challenges...
    🕹️ p5.js Web Editor Sketch: editor.p5js.org/codingtrain/s...
    🎥 Previous video: • Coding Challenge #92: ...
    🎥 Next video: • Coding Challenge #94: ...
    🎥 All videos: • Coding Challenges
    References:
    🔴 Physics Lab Double Pendulum: www.myphysicslab.com/pendulum...
    Videos:
    🚂 Pendulum Simulation: • 3.4: Pendulum Simulati...
    🔴 Coding Train Live 120: • Live Stream #120: MNIS...
    Related Coding Challenges:
    🚂 #86 Cube Wave by Bees and Bombs: • Coding Challenge #86: ...
    🚂 #159 Simple Pendulum Simulation: • Coding Challenge #159:...
    Timestamps:
    0:00:00 Double Pendulum Simulation
    0:03:45 Creating The Double Pendulum
    0:08:35 Adding The Tracing of The Path
    0:12:51 Implementing The Double Pendulum Formulas
    0:24:45 Visualizing It
    0:28:21 Adding Damping
    0:29:16 Conclusions And Suggestions
    Editing by Mathieu Blanchette
    Animations by Jason Heglund
    Music from Epidemic Sound
    🚂 Website: thecodingtrain.com/
    👾 Share Your Creation! thecodingtrain.com/guides/pas...
    🚩 Suggest Topics: github.com/CodingTrain/Sugges...
    💡 GitHub: github.com/CodingTrain
    💬 Discord: thecodingtrain.com/discord
    💖 Membership: ua-cam.com/users/thecodingtrainjoin
    🛒 Store: standard.tv/codingtrain
    🖋️ Twitter: / thecodingtrain
    📸 Instagram: / the.coding.train
    🎥 Coding Challenges: • Coding Challenges
    🎥 Intro to Programming: • Start learning here!
    🔗 p5.js: p5js.org
    🔗 p5.js Web Editor: editor.p5js.org/
    🔗 Processing: processing.org
    📄 Code of Conduct: github.com/CodingTrain/Code-o...
    This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecod...
    #doublependulum #pendulumharmonicmotion #processing

КОМЕНТАРІ • 737

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

    13:15
    Note: the following proof is trivial and has been left as an exercise to the reader

    • @tooljockey2777
      @tooljockey2777 4 роки тому +2

      lmfao love those videos

    • @jirobow
      @jirobow 4 роки тому +9

      Physics books be like

    • @Commanderdata-po6ym
      @Commanderdata-po6ym 4 роки тому +7

      Lagrange bra.

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

      ua-cam.com/video/tc2ah-KnDXw/v-deo.html
      in case you are interested ;)

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

      @ bill bassichis

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

    Fun fact in case nobody else has mentioned it: updating the positions using the "current velocity" vs the previous one changes the numerical method from Euler's method to the Euler-Cromer method, which is quite a lot more accurate. The regular Euler method is prone to inadvertently increasing the energy of the system, while the Euler-Cromer method conserves energy quite decently. The two methods seem almost identical, but the behind the scenes math is quite interesting and shows that they are actually of different orders.

  • @Phi1618033
    @Phi1618033 4 роки тому +186

    "Okay, I'm gonna see if I can just copy and paste this enormous differential equation right into my code."

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

    i have no idea wats going on. yet im enjoying this video.

  • @missingsemi
    @missingsemi 6 років тому +1839

    “G is the universal gravitational constant, I assume. That’s just gonna be one.”

    • @nathanaelgodon1603
      @nathanaelgodon1603 6 років тому +90

      If only it became true at the moment he wrote it ! Some physics genius would have re-died. ^^

    • @aidenwatler7153
      @aidenwatler7153 6 років тому +181

      Missing Semicolon I died. Small g is acceleration of gravity on earth = 9.81 m/s^2. Big G is the universal gravitational constant, 6.67 x 10^-11. TRIGGERED!!!

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

      Most of the time you don't use actual real values in code because in order to have them work properly ud have to do a lot more work.

    • @PatMende
      @PatMende 6 років тому +129

      ħ = c = G = 1

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

      This was golden hahahah thank you so much for this

  • @AdityaFingerstyle
    @AdityaFingerstyle 6 років тому +275

    To those who want to make this simulation more real do this.
    Currently Dan is setting g = 1. Although its far from the actual value the simulation looks very real.
    This is because one second in the simulation is one frame. And by default processing or p5.js is set to 60 fps.
    This means when one second passes in real world, 60 seconds would have passed in the simulation world.
    Hence the correct value of g would be 9.8/ ( 60 * 60 ) .
    There's still one more thing to adjust. The masses are actually in kilograms hence you should set the value of bob masses to around 0.05 which is 50 grams. Also, the lengths are in meters so make that they aren't very large.

    • @TheCodingTrain
      @TheCodingTrain  6 років тому +65

      Thanks for these comments!

    • @SRAVANAM_KEERTHANAM_SMARANAM
      @SRAVANAM_KEERTHANAM_SMARANAM 4 роки тому +9

      This Guy has made a magic. But when we give the real numbers within no time, the software is getting into errors. he has very intelligently demonstrated the capabilities given the limitation of a 30 min video. The world appreciated him for this.

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

      Nope

    • @sethmobit
      @sethmobit Рік тому +1

      I changed and now it's really really slow

  • @joaovitordasilvabonadiman8303
    @joaovitordasilvabonadiman8303 6 років тому +267

    OMG, I've watched a 30 min video without even noticing it. Thanks for existing, Dan!

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

      João Vitor Bonadiman
      Same...
      When I noticed the video would end soon from the way he talked I looked up the runtime because I hoped there was more to come with messing with the values. Then I noticed I've watched 30 min of coding feeling like 5...

  • @lepetrolophiledu6221
    @lepetrolophiledu6221 6 років тому +450

    I really REALLY laughed when the pendulum just started warping into another dimension at 12:30
    *"See, this is kind of the idea"*

    • @purnya2
      @purnya2 6 років тому +7

      you just made my day hahahaha

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

      Hahahaha

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

      He just made the flower of life

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

      Was my thought too :D

  • @matthimf
    @matthimf 4 роки тому +68

    24:10 you are changing the integration method from simple explicit Euler to symplectic Euler which is numerically much more stable.

    • @rboyce1000
      @rboyce1000 4 роки тому +17

      Top comment!! This explains your astute observation at 23:33 "It's got quite a bounce to it." The simple/forward Euler method tends to artificially add energy to this system, while the symplectic/semi-implicit Euler method is better at conserving energy. There are many other variant methods, including the so-called midpoint method (angle is updated by the average of present and future velocity steps).

    • @Chandrashekar-fd1dg
      @Chandrashekar-fd1dg 3 роки тому +10

      W h a t

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

      I found some math gods here...

  • @TheUltimateVanquish
    @TheUltimateVanquish 6 років тому +121

    I think a cool feature to add would be a fade of the trace line, so as a segment of line is drawn, say 5 seconds later it begins to fade, so you only ever have the last 5 or so seconds of trace at any given time

    • @bard-anilsen
      @bard-anilsen 4 роки тому +5

      Something like this in draw:
      fill(255,10);
      rect(0,0,width,height);

  • @ayjaygame
    @ayjaygame 6 років тому +9

    I never knew i could be so engaged and laugh at someone doing something like this. Great video! :)

  • @nathannolte4333
    @nathannolte4333 4 роки тому +60

    17:49
    "Oh I forgot a semi colon"
    Me: (Laughs in Python)

    • @killereks
      @killereks 4 роки тому +20

      Imagine running your programs at 60 fps
      Me: laughs in c++

    • @thewild2334
      @thewild2334 4 роки тому +2

      @@killereks imagine not having Dynamic Memory Allocation
      Me: also laughs in python

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

      @@thewild2334 imagine spending too much memory on a slow list.
      Me: laughs in C

    • @cloudyshows3674
      @cloudyshows3674 4 роки тому +2

      @@killereks Imagine running your program in the browser.
      Me: laughs in JavaScript

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

      why did you guys stop??

  • @TheDyingPlant
    @TheDyingPlant 2 роки тому +4

    You’re one of those special people in the world that make it a better place. You can always tell, and it just radiates from you.

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

    I'm so happy you've done this; I started making one of these in P5 using a class, and I just figured you'd use basic Trig to calculate the angles. Had literally no idea the lre was a huge algorithm derived for it! Gonna give this a looking soon!

  • @MicheleMerlino-yb3og
    @MicheleMerlino-yb3og Рік тому +4

    We need more teachers like you, I'm starting to enjoy coding thanks to you!

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

    this is the first of your videos i have seen, i am so glad people actally go through these sort of things for others to see
    keep up the good work :)

  • @taylorjeffery4145
    @taylorjeffery4145 4 роки тому +104

    "I'm not going to derive those formulas" *cries in physics major

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

      @Max Beer more easy to use Hamiltonian

    • @mr.mirror1213
      @mr.mirror1213 4 роки тому

      @@termitori Hamiltonian is advanced Lagrange

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

      @@mr.mirror1213 but it makes it so easy. the hamiltonian destroys everything you thought you knew about classical mechanics and it's fucking beautiful

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

      Exactly man, after using lagrangian it bacame easior

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

    Idk why this was recommenced to me, I never even coded, but you're so full of energy and entertaining, thumbs up dude

  • @JeffBezosOfficial
    @JeffBezosOfficial 4 роки тому +2

    First video I watch from this genius. You’re funny as hell, your channel’s gonna get me hooked. Thanks.

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

    you are a blessing !!!! a true blessing. I cant thank you enough for what you are doing.

  • @blutstein1210
    @blutstein1210 6 років тому +123

    The first time i see, why i had to learn all the Math in school xD

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

      All those physics courses really made me understand this, I'd be lost without taking those courses tbh.

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

    It's so satisfying to see the joy on his face as if he became a father😄great man to be convinced to get into coding

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

    THIS IS A PERFECT EXAMPLE OF HOW TO DO AND HANDLE COMPLEX PROJECTS AND COMPLEX ALGORITHM. YOU'RE GREAT!!

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

    This is the best UA-cam channel I've ever seen

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

    Pretty cool! A few things: the dampening should be a function of velocity, proportional using some constant. It would be harder/maybe fun to calculate the forces along the bars and have them extend elastically under the load.

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

    There is a small error here in the equations of motion. Because the canvas draws the origin in the top left, the derivation used here is slightly wrong. This is accounted for in drawing the pendulum. However the error propagates into the angular acceleration equation.
    There are two ways to fix this:
    1) Fix the equations of motion by doing a coordinate transformation of the solution
    g -> -g, and cos(angle1) and cos(angle2) also go to negatives. This is actually a bit harder than it looks because there are a lot of trig identities you'd need to pull out to di this.
    2) Fix the coordinate system
    When I implemented this myself using plain old JavaScript the Canvas Context object allows you to scale it by a negative number. Then fix how you draw the pendulums so y = -cos(angle) * length. I believe a way to accomplish this in Processing would be the rotateX() function.

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

      Thank you for this feedback!

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

      hey, I've encountered the exact same problem you pointed out, could you help me with it in more detail ? I'm kinda lost. For g--> - g, easy to understand but what do I do for the trig identities ? Thanks

  • @LuisHerrera-gi8wu
    @LuisHerrera-gi8wu 6 років тому +1

    You do great videos, congrats!!!

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

    Make a pendulum wave, multiple pendulums with differents arm length, that effect is pretty awesome !!

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

    awesome :D i always get so excited when i see a new video on this channel. I even managed to attend some live streams.
    I love how weird you are :D and how you can explain these pretty complicated concepts in a way that is so easy to understand.
    I've tried the same with the matter.js library but failed miserably :p nicely done!

  • @CedricRBR
    @CedricRBR 6 років тому +24

    Quick wallpaper I did using this: i.imgur.com/BSb37so.png

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

    You are the one Level 99 developer that I've spent my entire life looking for. If there was a 10th Dan for programmers, it'd be yours. Thanks for existing.

  • @ian-evanmichel8185
    @ian-evanmichel8185 6 років тому +2

    And by the way, if you or anyone else want to solve the problem at the end ( I mean that the pendulum is getting higher and higher and even faster) you need to use another way to solve numerically the differential equations.
    Here you used the Euler method (explicit) ( v += a and x+=v).
    There is a loose of accuracy because of the integration step.
    In order to fix it (or to make it better) you can use the RK4-method (Runge Kutta 4) which will make you gain in accuracy without reducing the integration step of time (which is expensive in terms of calculation time).
    I know it's a bit more complicated but it's worth it ( I personally have tested it with pendulums and with gravity simulation with planets and orbits which can degenerate).

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

    man , watching this smart and fun guy is another level of happiness :D !

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

    that is VERY hard to create a double pendulum, just because it's so random and hard! I didn't watched the video yet, because as always; I'm first trying the challenge myself and then trying your code. This one was IMPOSSIBLE!! good job Dan!!!

  • @user-zb8tq5pr4x
    @user-zb8tq5pr4x 4 роки тому +4

    You should try to create a simulation with vectors as well, it would be interesting.
    (Calculate the motions without formulas, just using vectors and addition)

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

    Wow, Dan! I didn't know you are so good at object oriented programming!

  • @celiacasimiro465
    @celiacasimiro465 4 роки тому +4

    22:50 The most beautiful sound you can hear...

  • @johanrojassoderman5590
    @johanrojassoderman5590 4 роки тому +27

    "I'm right about the angular acceleration, because it's going in a perfect circle"
    - Dan 2018

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

    i've literally never watched a coding video before (but i've at least taken calc and physics haha) but somehow this made sense, so props to you as a teacher!

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

      Glad to hear! You can use either of these playlists to start from the beginning!
      ua-cam.com/users/shiffmanplaylists?view=50&shelf_id=14&sort=dd
      ua-cam.com/users/shiffmanplaylists?view=50&shelf_id=2&sort=dd

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

    This was my second year BSc Physics coding project (circa 2016). It was hardcore, but definitly do-able :D

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

    Dude you are a gifted individual.

  • @nietschecrossout550
    @nietschecrossout550 6 років тому +154

    15:00 you hurt the physicist in me so darn hard XD

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

      René Carannante Actually, that's exactly what a physicist would have done. We set constants to 1 all the time. Like in relativity, c is always 1

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

      First of all, c is simply the speed of light, it is NOT 1. In special relativity we treat it as 1 because that's the the ratio speed of light/speed of light = 1 , and other speeds are written in terms of c so it's easier to do lorentz transformations.
      Physicists don't set constants. Ever. You can't just set a constant to whatever you want.

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

      Pati, clearly you aren't a physicist. There is nothing fundamental about the meter or the second that makes them absolute in any way. All dimensional constants are dependent entirely on the measuring system you use them with. Who sets the measuring system? Physicists. You CAN set the speed of light to whatever you want, just by using whatever length you want. It's not just a notational trick, the speed of light IS one lightyear per year, or one lightsecond per second, etc.
      The only FUNDAMENTAL constants are the dimensionless ones, like the fine structure constant or the strong coupling constant, dimensional constants like the speed of light and gravitational constants are all secondary.

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

      Pati I think you must understand that anything can be referenced in relation to everything, regarding certain vectors of location and assuming small scale locality and infinite spatial dimensions of said locality. Therefore, symbology and meaning in this world is manifested solely based on our reality and thought processes from the point of which we stand.
      There’s a reason why everyone else besides the US uses the metric system. Because it’s easier to work with. Why would you want to make things harder for yourself?

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

      @@pati7132 I agree

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

    This was awesome. Thanks!

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

    Absolutely love you videos. I also found out that if you try to compute the total energy of the system, it is NOT conserved, I wonder what is wrong, everything seems to work fine except that

  • @ChaoteLab
    @ChaoteLab 6 років тому +49

    Go Dan! GO!

  • @JW-pq1ml
    @JW-pq1ml 5 років тому +19

    I just found my new favorite channel.

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

    that was awesome man!!

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

    That probably the craziest formula I've ever seen

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

    You are simply awesome!!!

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

    I go to know so many things related to coding bcuz of you thanks a lot for making such amazing tutorials. Now I can kinda convert Java into Javascript(as thats the only language I know). They are so fun to follow along!!!

  • @Morszczux
    @Morszczux 6 років тому +29

    Now me as a physics student want to make 3D version where all of the formulas are calculated by me! Funny thing is that last semester I had classes called Classical Mechanics and one of the tasks on final exam was to calculate this formulas in double pendulum ;>

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

      Sounds hella fun. Would love to see a 3d version!

    • @mr.fluffypantz4150
      @mr.fluffypantz4150 6 років тому +13

      Morszczux Lagrangians save lives

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

      Mr. Fluffypantz True!

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

    Amazing... Chaos moviment.. and the butterfly effect. You are great!

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

    Cara, muito pai dégua teu trabalho!

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

      Professor de Física Ele aceitou na programação mas errou na física

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

    You are surely the best coding tutor available

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

    Thanks for introducing me to Processing....

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

    You can check your code by making both angles kept equal throughout and starting out with a small angle such that it recreates a rigid rotor case.

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

    Great Video, thanks for sharing.

  • @5_inchc594
    @5_inchc594 4 роки тому

    For those who does not understand why at 24:30, switching the velocity before position fixed the problem, here is the technical explanation:
    it seems like its the same, but if you work out the math, position first is called Euler's method whose error is not bounded. As time goes by, the error will be big enough(if you plot the energy of the system, it continuously goes up) , it seems like it getting more energetic. If you put the velocity before the position, the error is bounded. He accidentally used a method called Verlet method whose error is bounded in this case. therefore, as time goes by, the energy of the system fluctuate within in a range, therefore, it looks real.

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

    29:03 actually you don't need that dampening since you have in the g value, since it's 1 it won't really change the result of the formula but if you tweak it to be 9,807 m/s² (earth gravity) it'd change, I like moon, mars and sun values to play with.

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

    So much fun watching this

  • @m.sierra5258
    @m.sierra5258 6 років тому +7

    Hey! I'd love to see you implement the '4th order runge kutta' method for that. What you did (v+=a; x+=v) is called 'Forward Euler Integration', 'Runge Kutta Integration' is basically the same, but with multiple intermediate steps. That achieves an accuracy that goes down two more taylor iterations, removing the 'energy gain' over time.

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

      Yes, it would be nice to cover this sometime!

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

      I did that here for multiple pendula: github.com/kevinhp/multiplePendula

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

      See here for a working implementation:
      www.openprocessing.org/sketch/507468
      Cheers, Daniel

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

    The reason that updating the velocities and then the positions works better is because it's a symplectic forward Euler integration scheme which more closely captures the symplectic geometric structure of the (Hamiltonian) double pendulum system, and so you get less numerical integration error. You can also write down the general equations of motion for a generalized pendulum fairly easily in the case where the lengths and masses of the pendulums are the same, and I'm sure it's just a tedious generalization to consider distinct masses and lengths.

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

    The double pendulum is a system of four first order non-linear differential equations. A better method of approximating the solution would be an ODE solving algorithm like Runge-Kutta. Simply adding acceleration to velocity and velocity to position will only be valid for a very short time interval after release due compounding error.

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

    It was interesting, thank you)

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

    The pendulum going crazy is my favoirite part

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

    Rather than calculate the angles, I calculated the force in the connecting rods and used a pair of standard movers, with the child pendulum applying its rod force to the parent pendulum. Seems to work fairly well. I also call canvas.background() with a very transparent color so the trace fades over time.

  • @purifierphoenixthemecca2074
    @purifierphoenixthemecca2074 6 років тому +35

    Next challenge
    Gravitational Waves

  • @marco.nascimento
    @marco.nascimento 6 років тому

    wow, that's pretty awesome.

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

    g is acceleration due to gravity
    G is the universal gravitational constant

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

    This code helped me make a spirograph generator.

  • @danielw.4876
    @danielw.4876 4 місяці тому

    One tiny thing I would change is making the width and height of the masses proportional to the square root of the mass, that way the area is proportional to the mass.

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

    7:36 You could delete that second fill function call just before the ellipse function call you are in this moment, sine the you are just resetting it to the same value. Indeed, the program also works if you move the fill function call to setup()

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

    For those interested, formula comes from approximating Runge Kutta numerical solution. You might as well program it so you do not have the need to write the "analytical" solution.

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

    Awesome !

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

    25 mins in and I'm subbing. You're awesome. If you need help with understanding these equations I would be happy to help out. I'm an currently a master engineering student in the Netherlands. And I know python language coding

  • @phrostbit3n
    @phrostbit3n 4 роки тому +6

    "Somebody crazy calculated it"
    Yes, intro phys students are absolutely insane

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

    You are really awesome man.

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

    Dan, i would like to challenge you to recreate this but in 3D. Still a double pendulum but can rotate along a z axis aswell. Think this would make a cool project, since it seems like a very difficult thing to recreate in the real world.

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

      Two strings Two masses and a conection to the celling. but a simulation would be cool either way.

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

    Hi , I have a doubt. Without getting the function called , how is there constant incrementing and decrementing in the first third of the video?

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

    12:43 hmm that pendulum looks like a famous logo... that's a new brand I believe?

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

    95/5000
    it will not be the same pattern, the inverted pendulum is a non-linear and chaotic system ... great work

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

    It could be a good beginner project, specifically for people learning to deal with neural networks, to train a neural network to predict a double pendulum.

  • @Victor-em1ms
    @Victor-em1ms 6 років тому

    What is the font that you use to get those 'i' and 'l'?
    I like it a lot.

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

    The way to calculate the double pendulum is actually not incredibly complex. There's really 2 main things you have to know. 1.) you have to know the physics in order to get a formula for the kinetic and potential energy for each of the masses. 2.) you have to know the Euler-Lagrange equation. you use the formulas for the kinetic and potential energy to get two differential equations, and really the complicated part is the algebra for actually solving for the angular acceleration for theta1 and theta2 because the equations is a little long and both accelerations show up in both equations. The original differential equation is (relatively) simpler and not too complex to see where each part of the equation comes from.

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

    I love your work so much

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

    "that seemed to have fixed it" -every coder working on bugs

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

    Loved it

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

    One question, what video editor do you use to overlap you so smoothly to your screen? Thx

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

    You're using the 1st order Euler method to solve the differential equations, it is very rough and you get the increasing total energy to your system with time. Check please the sum of kinetic and potential energy of the pendulum. To fix the problem you should damp the velocity in such a way that the energy is kept constant.

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

    What font is that which is used in the text editor in this video, it looks really nice?

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

    I love this guy

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

    In the limit as _r2_ , _m2_ → 0 and _r1_ , _m1_ get large the behaviour should in theory also start to approach that of a single pendulum

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

    Update the velocity before the position, it is a more stable integration method (semi-implicit euler integration)

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

    I know absolutely nothing about coding and all of this is foreign to me but I love watching you lol

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

    Mathematical art's great for introducing kids to math, physics and programming. This 2D representation of a 3D object captures interesting properties of a double pendulum, but I'd imagine that 2DoF robotic arms (Scara configurations?) probably treat it better. What I'd like to see is a colored map that shows where the pendulum weights spend most of their time and I'd like to see implementations of quantum algorithms to generate it. I'd guess it would resemble a blobby v shape. I bet this has a name and a figure, but I have yet to come across it.
    Also, if the video outlined coding concepts it covers, it would be more useful for structured learning, for example in school.

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

      P.S. While looking for previous Processing tutorials about double pendulums, this guy popped up and I think he looks like Metro/Music Man; no offense, just an observation.
      scripps.ucsd.edu/profiles/hstaudigel

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

    BTW, those 'crazy' expressions of accelerations can be derived using euler-langrange equation (a part of langrangian mechanics). Infact, It's very simple, not crazy at all :)

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

    Just, wow.

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

    Any idea why the translate function is not translating to the coordinate (300, 50)? It draws the tracing points at the origin (0, 0). I tried with the translate func at different places, no effect. I am at 12:40

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

    Hi, this is a great video! Could you please tell me the environment you have for coding. Like language and libraries, etc. ?

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

      This video uses Processing (which is built on top of the Java programming language). For more info, visit processing.org and also this video might help ua-cam.com/video/AmlAiKsiy0o/v-deo.html.

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

    What environment do you code in? How can you have all the methods without having to import a library? Also is that java?