Coding Challenge 93: Double Pendulum

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: kzread.infojoin
🛒 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

Пікірлер: 738

  • @RedTriangle53
    @RedTriangle535 жыл бұрын

    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.

  • @sarath_sajan
    @sarath_sajan5 жыл бұрын

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

  • @tooljockey2777

    @tooljockey2777

    4 жыл бұрын

    lmfao love those videos

  • @jirobow

    @jirobow

    4 жыл бұрын

    Physics books be like

  • @Commanderdata-po6ym

    @Commanderdata-po6ym

    4 жыл бұрын

    Lagrange bra.

  • @quink3

    @quink3

    4 жыл бұрын

    kzread.info/dash/bejne/ppdmw8pme9GqiNo.html in case you are interested ;)

  • @erickelley9888

    @erickelley9888

    4 жыл бұрын

    @ bill bassichis

  • @Phi1618033
    @Phi16180335 жыл бұрын

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

  • @missingsemi
    @missingsemi6 жыл бұрын

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

  • @nathanaelgodon1603

    @nathanaelgodon1603

    6 жыл бұрын

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

  • @aidenwatler7153

    @aidenwatler7153

    6 жыл бұрын

    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 жыл бұрын

    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 жыл бұрын

    ħ = c = G = 1

  • @eddyrose3254

    @eddyrose3254

    6 жыл бұрын

    This was golden hahahah thank you so much for this

  • @joaovitordasilvabonadiman8303
    @joaovitordasilvabonadiman83036 жыл бұрын

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

  • @nicerholunder9414

    @nicerholunder9414

    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...

  • @photon2724
    @photon27245 жыл бұрын

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

  • @softpaw6234

    @softpaw6234

    3 жыл бұрын

    Story of my life online

  • @kaledbrahmi3442

    @kaledbrahmi3442

    3 жыл бұрын

    Same

  • @wolfevan5880

    @wolfevan5880

    2 жыл бұрын

    Same

  • @technicallokaya6726

    @technicallokaya6726

    2 жыл бұрын

    Like 2 livers connected and if we swing it from the free end, it creates a beautiful art. I guess that's what he did. Not sure.

  • @thedarkknightclipss

    @thedarkknightclipss

    2 жыл бұрын

    😂😂😂 Me too

  • @lepetrolophiledu6221
    @lepetrolophiledu62216 жыл бұрын

    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 жыл бұрын

    you just made my day hahahaha

  • @otesunki

    @otesunki

    5 жыл бұрын

    Hahahaha

  • @_news_of_the_world_

    @_news_of_the_world_

    5 жыл бұрын

    He just made the flower of life

  • @Miaumi

    @Miaumi

    5 жыл бұрын

    Was my thought too :D

  • @AdityaFingerstyle
    @AdityaFingerstyle6 жыл бұрын

    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 жыл бұрын

    Thanks for these comments!

  • @SRAVANAM_KEERTHANAM_SMARANAM

    @SRAVANAM_KEERTHANAM_SMARANAM

    4 жыл бұрын

    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

    Жыл бұрын

    I changed and now it's really really slow

  • @ayjaygame
    @ayjaygame6 жыл бұрын

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

  • @DowzerWTP72
    @DowzerWTP726 жыл бұрын

    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!

  • @TheDyingPlant
    @TheDyingPlant2 жыл бұрын

    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.

  • @MicheleMerlino-yb3og
    @MicheleMerlino-yb3og Жыл бұрын

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

  • @TheUltimateVanquish
    @TheUltimateVanquish6 жыл бұрын

    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 жыл бұрын

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

  • @CedricRBR
    @CedricRBR6 жыл бұрын

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

  • @ayeyefookinw0tm859

    @ayeyefookinw0tm859

    6 жыл бұрын

    Cédric Reber nice wallpaper

  • @TheTanmaybishnoi

    @TheTanmaybishnoi

    6 жыл бұрын

    Too Good

  • @tryphonunzouave8384
    @tryphonunzouave83845 жыл бұрын

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

  • @cashel1111
    @cashel11116 жыл бұрын

    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 :)

  • @matthimf
    @matthimf4 жыл бұрын

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

  • @rboyce1000

    @rboyce1000

    4 жыл бұрын

    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 жыл бұрын

    W h a t

  • @prerit714

    @prerit714

    Жыл бұрын

    I found some math gods here...

  • @JeffBezosOfficial
    @JeffBezosOfficial4 жыл бұрын

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

  • @anujmithbavkar9933
    @anujmithbavkar99335 жыл бұрын

    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

  • @hmd5298
    @hmd52985 жыл бұрын

    This is the best KZread channel I've ever seen

  • @ChaoteLab
    @ChaoteLab6 жыл бұрын

    Go Dan! GO!

  • @talkingtornedo3054
    @talkingtornedo30546 жыл бұрын

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

  • @klivecorps
    @klivecorps2 жыл бұрын

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

  • @blutstein1210
    @blutstein12106 жыл бұрын

    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.

  • @toastrecon
    @toastrecon6 жыл бұрын

    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.

  • @TheCodingTrain

    @TheCodingTrain

    6 жыл бұрын

    thanks for this feedback!

  • @victoralvesbugueno6178
    @victoralvesbugueno61786 жыл бұрын

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

  • @LuisHerrera-gi8wu
    @LuisHerrera-gi8wu6 жыл бұрын

    You do great videos, congrats!!!

  • @ethanhermsey
    @ethanhermsey6 жыл бұрын

    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!

  • @nathannolte4333
    @nathannolte43334 жыл бұрын

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

  • @killereks

    @killereks

    4 жыл бұрын

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

  • @thewild2334

    @thewild2334

    4 жыл бұрын

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

  • @killereks

    @killereks

    4 жыл бұрын

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

  • @cloudyshows3674

    @cloudyshows3674

    4 жыл бұрын

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

  • @tathagatmaheshwari6685

    @tathagatmaheshwari6685

    4 жыл бұрын

    why did you guys stop??

  • @Invalid571
    @Invalid5716 жыл бұрын

    A detailed explanation on how to derive the equations of motion for the double pendulums: kzread.info/dash/bejne/oJmcmpiuZ8K6ec4.html

  • @TheCodingTrain

    @TheCodingTrain

    6 жыл бұрын

    Thanks for this reference!

  • @binarysaiyan9389
    @binarysaiyan93894 жыл бұрын

    You are simply awesome!!!

  • @yahia1355
    @yahia13554 жыл бұрын

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

  • @taylorjeffery4145
    @taylorjeffery41454 жыл бұрын

    "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 жыл бұрын

    @@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

  • @aradarbel4579
    @aradarbel45796 жыл бұрын

    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!!!

  • @masterflamaster6377
    @masterflamaster63776 жыл бұрын

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

  • @ricardosallin1670
    @ricardosallin16704 жыл бұрын

    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.

  • @ricard458
    @ricard458 Жыл бұрын

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

  • @DaviAyres
    @DaviAyres5 жыл бұрын

    This was awesome. Thanks!

  • @heliumhydride
    @heliumhydride4 жыл бұрын

    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

  • @user-zb8tq5pr4x
    @user-zb8tq5pr4x4 жыл бұрын

    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)

  • @ujjwaladitya1042
    @ujjwaladitya10423 жыл бұрын

    You are surely the best coding tutor available

  • @kenzarezyarifin1076
    @kenzarezyarifin10763 жыл бұрын

    That probably the craziest formula I've ever seen

  • @johanrojassoderman5590
    @johanrojassoderman55904 жыл бұрын

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

  • @CanadianMang
    @CanadianMang6 жыл бұрын

    Dude you are a gifted individual.

  • @lukasaudir8
    @lukasaudir85 жыл бұрын

    that was awesome man!!

  • @yovhal1980
    @yovhal19803 жыл бұрын

    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!!!

  • @kajhall3581
    @kajhall35814 жыл бұрын

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

  • @josebreijo3850
    @josebreijo38506 жыл бұрын

    So much fun watching this

  • @rashedulislam9301
    @rashedulislam93014 жыл бұрын

    You are really awesome man.

  • @ThenewmanX1
    @ThenewmanX1 Жыл бұрын

    Awesome !

  • @mkelly568
    @mkelly5685 жыл бұрын

    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! kzread.infoplaylists?view=50&shelf_id=14&sort=dd kzread.infoplaylists?view=50&shelf_id=2&sort=dd

  • @JW-pq1ml
    @JW-pq1ml6 жыл бұрын

    I just found my new favorite channel.

  • @ahzazz
    @ahzazz6 жыл бұрын

    Thanks for introducing me to Processing....

  • @jamesserenity8634
    @jamesserenity86342 жыл бұрын

    I love your work so much

  • @AdityaPutatunda
    @AdityaPutatunda4 жыл бұрын

    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.

  • @ian-evanmichel8185
    @ian-evanmichel81856 жыл бұрын

    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).

  • @sulfursw9286
    @sulfursw92865 жыл бұрын

    It was interesting, thank you)

  • @celiacasimiro465
    @celiacasimiro4654 жыл бұрын

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

  • @ssbmwine9387
    @ssbmwine93876 жыл бұрын

    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

  • @marco.nascimento
    @marco.nascimento6 жыл бұрын

    wow, that's pretty awesome.

  • @xetop
    @xetop6 жыл бұрын

    Great Video, thanks for sharing.

  • @destinyjames6117
    @destinyjames61173 жыл бұрын

    The pendulum going crazy is my favoirite part

  • @jooeeee
    @jooeeee3 жыл бұрын

    Thank you. Geat teacher :) !

  • @youngmatthewm
    @youngmatthewm6 жыл бұрын

    I actually coded one of these in p5js last spring. Check it out here: youngmatthewm.github.io/

  • @thomaswaller4517

    @thomaswaller4517

    6 жыл бұрын

    Matthew Young that’s really cool!

  • @youngmatthewm

    @youngmatthewm

    6 жыл бұрын

    Thomas Waller thanks. Feel free to pull down the code and play with it yourself. I found that using the simple derivatives led to regular oscillations, so changed to RK4 to do the updates. Let me know if you have any questions

  • @avananana

    @avananana

    6 жыл бұрын

    Ohh, I like the changing colour of the trace! Well done :P

  • @graysonmullins3167
    @graysonmullins31672 жыл бұрын

    This code helped me make a spirograph generator.

  • @harshitmalhotra8627
    @harshitmalhotra86276 жыл бұрын

    Loved it

  • @Tsskyx
    @Tsskyx6 жыл бұрын

    YES, finally :D

  • @NonTwinBrothers
    @NonTwinBrothers6 жыл бұрын

    haha, double pendulums are great

  • @Bunglay

    @Bunglay

    6 жыл бұрын

    lol

  • @jafetvargas5408
    @jafetvargas54086 жыл бұрын

    I love this guy

  • @ashishkingdom
    @ashishkingdom6 жыл бұрын

    Very nice!

  • @abrorabyyu6221
    @abrorabyyu62212 жыл бұрын

    this is the best way to learn how to convert equation to codee!

  • @profemanoelsilva
    @profemanoelsilva5 жыл бұрын

    Cara, muito pai dégua teu trabalho!

  • @marcioamaral7511

    @marcioamaral7511

    5 жыл бұрын

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

  • @5_inchc594
    @5_inchc5944 жыл бұрын

    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.

  • @zsigmondforianszabo4698
    @zsigmondforianszabo46983 жыл бұрын

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

  • @valentincontilde
    @valentincontilde3 жыл бұрын

    thank you so much

  • @Taterzz
    @Taterzz4 жыл бұрын

    the lagrange equations were fun.

  • @nietschecrossout550
    @nietschecrossout5506 жыл бұрын

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

  • @ObjectsInMotion

    @ObjectsInMotion

    6 жыл бұрын

    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

    6 жыл бұрын

    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

    6 жыл бұрын

    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 жыл бұрын

    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

  • @taylorjeffery4145
    @taylorjeffery41454 жыл бұрын

    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.

  • @Morszczux
    @Morszczux6 жыл бұрын

    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 жыл бұрын

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

  • @mr.fluffypantz4150

    @mr.fluffypantz4150

    6 жыл бұрын

    Morszczux Lagrangians save lives

  • @Morszczux

    @Morszczux

    6 жыл бұрын

    Mr. Fluffypantz True!

  • @charlie3k
    @charlie3k6 жыл бұрын

    Just, wow.

  • @good_brake
    @good_brake6 жыл бұрын

    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.

  • @TheCodingTrain

    @TheCodingTrain

    6 жыл бұрын

    Thanks for this information!

  • @jujhaarsingh7889
    @jujhaarsingh78895 жыл бұрын

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

  • @Wessen24
    @Wessen244 жыл бұрын

    Amazing

  • @CollinKeegan
    @CollinKeegan3 жыл бұрын

    Pausing it at the beginning to call how he's going to do it, build a single pendulum simulation and then create a piece of code to find the angle of the first pendulum and basically add the second onto the first.

  • @sonulohani
    @sonulohani6 жыл бұрын

    Love your videos....

  • @yjr4df758
    @yjr4df7583 жыл бұрын

    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.

  • @Metalefs1
    @Metalefs16 жыл бұрын

    You are an amazing person

  • @DarkRedman31
    @DarkRedman315 жыл бұрын

    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.

  • @americanmcgeesalicefanatic8904
    @americanmcgeesalicefanatic89045 жыл бұрын

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

  • @PhazterMaze
    @PhazterMaze5 жыл бұрын

    Just not even gunna mention this beautiful flower of life.... that's not what we're coding...

  • @Crazy1793
    @Crazy17936 жыл бұрын

    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

  • @federicopanichi9874
    @federicopanichi98744 жыл бұрын

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

  • @monky123344
    @monky1233444 жыл бұрын

    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.

  • @Victor-em1ms
    @Victor-em1ms6 жыл бұрын

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

  • @bigchicharito4813
    @bigchicharito48134 жыл бұрын

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

  • @danielw.4876
    @danielw.48765 ай бұрын

    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.

  • @carlesmanguiano
    @carlesmanguiano4 жыл бұрын

    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.

  • @vfnikster
    @vfnikster5 жыл бұрын

    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.

  • @ronaldjensen2948
    @ronaldjensen29484 жыл бұрын

    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.

  • @_dot_
    @_dot_2 жыл бұрын

    I've never worked with Processing so I was kinda confused that you didn't consider the delta time with the changes in x1, v1, a1, etc. Is there something they did in Processing to make that insignificant or would you implement it in a larger projects?