{"id":216,"date":"2021-11-30T04:40:19","date_gmt":"2021-11-30T04:40:19","guid":{"rendered":"https:\/\/tults.com\/?page_id=216"},"modified":"2022-04-26T00:04:52","modified_gmt":"2022-04-26T00:04:52","slug":"the-pendulum-project","status":"publish","type":"page","link":"https:\/\/tults.com\/index.php\/physics-maths-and-science\/the-pendulum-project\/","title":{"rendered":"The Pendulum Project"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Synopsis: The pendulum project was one that I undertook in university to create an inertial double pendulum simulator. The goal was to understand chaos, and to understand how chaos adapts and evolves in a controlled environment. On this page, we talk about point mass pendulum (where the center of gravity is located at the very end of the arm. The report associated with this assignment was based on an inertial double pendulum, where the center of mass is distributed along the entire arm. I have changed it up here for two reasons. Firstly, to make it unique to the assignment, so if some future student goes to copy my work, they will at least have to change some of the maths to get it to work, and secondly, it is far easier to do the maths on a point mass pendulum then it is to to do on an inertial pendulum.<\/p>\n\n\n\n<h3 class=\"has-text-align-left wp-block-heading\">Introduction<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In the world of physics, knowing exact initial conditions will always result in knowing exactly how an object will behave. In most cases, knowing approximate initial conditions can lead to an approximate solution. In other cases, such as that of the double pendulum, a tiny shift of any initial conditions will cause the trajectory of the pendulum to change drastically over time. The moment there is any difference in conditions, the result will be completely unique. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Why undertake the study of something like this? Well, two reasons, it is an excellent example of lagrangian mechanics, and chaotic objects inspire fascination in humans. We feel like we can predict it, understand it, and then the universe taunts us, spitting in our faces and doing exactly what we don&#8217;t expect and being chaotic. As Einstein said, &#8220;God does not play dice with the universe,&#8221; and chaotic systems feel like dice. Well, I see this as me fighting back against the universe, trapping its chaos in a simulation and forcing it to bow to my whim, my control, all the while pulling data from it, and performing analysis on it. The study of chaos is a traditional man vs god story, within a wrapper of fascinating mathematics and science. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Maths<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Before doing the maths on this, we need to understand what is going on, and define our variables. We are going to use the following image to define our variables for our maths. We can see from the diagram below the angles and values that we will be using. <\/p>\n\n\n\n<canvas id=\"PendulumPic\" style=\"border:1px solid #000000;\" width=\"300\" height=\"300\"><\/canvas>\n<script>\nvar time = 0;\nvar grav = 10;\nvar theta1 = 30*Math.PI\/180;\nvar length = 100;\n\nvar psi1 = -30*Math.PI\/180;\nvar arm2 = 100;\n\n\nvar c = document.getElementById(\"PendulumPic\");\nc.parentElement.style.textAlign = \"center\";\nvar ctx = c.getContext(\"2d\");\n\/\/make values clean\n\/\/Clear Screen\nctx.clearRect(0, 0, 300, 300);\n\/\/Draw arm\nctx.beginPath();\nctx.moveTo(150, 50);\nctx.lineTo(length*Math.sin(theta1)+150, 50+length*Math.cos(theta1));\nctx.stroke();\n\/\/Draw fulcrum\nctx.beginPath();\nctx.arc(150, 50, 5, 0, 2 * Math.PI);\nctx.fillStyle = '#808080';\nctx.fill();\nctx.stroke();\n\/\/draw pendulum1\nvar x1 = length*Math.sin(theta1)+150;\nvar y1 = 50+length*Math.cos(theta1);\nvar x2 = 150 - length*Math.sin(theta1) - arm2*Math.sin(psi1);\nvar y2 = 50 + length*Math.cos(theta1) + arm2*Math.cos(psi1);\nctx.beginPath();\nctx.moveTo(x1, y1);\nctx.lineTo(x2, y2);\nctx.stroke();\n\n\nctx.beginPath();\nctx.arc(x1, y1, 20, 0, 2 * Math.PI);\nctx.fillStyle = '#FFDFBF';\nctx.fill();\nctx.stroke();\n\/\/Draw pendulum2\n\/\/ Draw pendulum\nctx.beginPath();\nctx.arc(x2, y2, 20, 0, 2 * Math.PI);\nctx.fillStyle = '#CCB7E5';\nctx.fill()\nctx.stroke();\n\n\/\/ Draw lines\nfor(var i = 0; i < 5; i++){\nctx.beginPath();\nctx.moveTo(150, 50+i*15);\nctx.lineTo(150, 60+i*15);\nctx.stroke();\n}\n\nfor(var i = 0; i < 5; i++){\nctx.beginPath();\nctx.moveTo(x1, y1+i*15);\nctx.lineTo(x1, y1+10+i*15);\nctx.stroke();\n}\n\n\/\/ Draw angle arcs\nctx.beginPath();\nctx.arc(150, 50, length\/2, theta1*2, Math.PI\/2);\nctx.stroke();\n\nctx.beginPath();\nctx.arc(x1, y1, arm2\/2, Math.PI\/2, 2*Math.PI\/3);\nctx.stroke();\n\nctx.beginPath();\nctx.font = \"20px Arial\";\nctx.fillStyle = '#FFA500';\nctx.fillText(\"\\u03B8\", 153, 90);\nctx.stroke();\n\nctx.beginPath();\nctx.fillStyle = '#800080';\nctx.fillText(\"\\u03C6\", 185, 174);\nctx.stroke();\n\nctx.beginPath();\nctx.fillStyle = '#000000';\nctx.fillText(\"L1\", 180, 90);\nctx.stroke();\n\nctx.beginPath();\nctx.fillStyle = '#000000';\nctx.fillText(\"L2\", 150, 174);\nctx.stroke();\n\n<\/script>\n\n\n\n<p class=\"wp-block-paragraph\">So with that in mind, we can start doing the maths. The first thing we will need to do is figure out the positioning of the two masses with respect to each-other. This can be defined as below (on a side note, how pretty is it having LateX on a website):<\/p>\n\n\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 14px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tults.com\/wp-content\/ql-cache\/quicklatex.com-39f3313f5f6584c8548e5292846743a0_l3.svg\" height=\"14\" width=\"73\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#120;&#32;&#61;&#32;&#120;&#32;&#43;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 14px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tults.com\/wp-content\/ql-cache\/quicklatex.com-36ffd69c6395cd7c8f8787819837832f_l3.svg\" height=\"14\" width=\"102\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#32;&#120;&#95;&#49;&#32;&#61;&#32;&#108;&#95;&#49;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#115;&#105;&#110;&#32;&#92;&#116;&#104;&#101;&#116;&#97;&#32; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 16px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tults.com\/wp-content\/ql-cache\/quicklatex.com-0027ca4707c90002b788bbfc0777cfeb_l3.svg\" height=\"16\" width=\"114\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#121;&#95;&#49;&#32;&#61;&#32;&#45;&#108;&#95;&#49;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#99;&#111;&#115;&#32;&#92;&#116;&#104;&#101;&#116;&#97; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 16px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tults.com\/wp-content\/ql-cache\/quicklatex.com-4e0a12c84c55b43db58a39dbfe327748_l3.svg\" height=\"16\" width=\"186\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#32;&#120;&#95;&#50;&#32;&#61;&#32;&#108;&#95;&#49;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#115;&#105;&#110;&#32;&#92;&#116;&#104;&#101;&#116;&#97;&#32;&#43;&#32;&#108;&#95;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#115;&#105;&#110;&#32;&#92;&#112;&#115;&#105;&#32; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 16px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tults.com\/wp-content\/ql-cache\/quicklatex.com-972eab54275d6d2b60d042f654390705_l3.svg\" height=\"16\" width=\"184\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#121;&#95;&#50;&#32;&#61;&#32;&#108;&#95;&#49;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#99;&#111;&#115;&#32;&#92;&#116;&#104;&#101;&#116;&#97;&#32;&#45;&#32;&#108;&#95;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#99;&#111;&#115;&#32;&#92;&#112;&#115;&#105; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In order to properly calculate the lagrangian we will need the kinetic energy, which will require the velocities of the two pendulum, which can be found by taking the derivative of the displacement, which can be seen as follows:<\/p>\n\n\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 19px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tults.com\/wp-content\/ql-cache\/quicklatex.com-58cbf9093221c2ff0f6abf29b88b2406_l3.svg\" height=\"19\" width=\"110\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#100;&#111;&#116;&#123;&#120;&#125;&#95;&#49;&#32;&#61;&#32;&#108;&#95;&#49;&#32;&#92;&#100;&#111;&#116;&#123;&#92;&#116;&#104;&#101;&#116;&#97;&#125;&#92;&#99;&#100;&#111;&#116;&#32;&#99;&#111;&#115;&#32;&#92;&#116;&#104;&#101;&#116;&#97; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 21px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tults.com\/wp-content\/ql-cache\/quicklatex.com-9f3a56898e47f8ba87cc0a92553ff34d_l3.svg\" height=\"21\" width=\"108\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#100;&#111;&#116;&#123;&#121;&#125;&#95;&#49;&#32;&#61;&#32;&#108;&#95;&#49;&#32;&#92;&#100;&#111;&#116;&#123;&#92;&#116;&#104;&#101;&#116;&#97;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#115;&#105;&#110;&#32;&#92;&#116;&#104;&#101;&#116;&#97; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 21px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tults.com\/wp-content\/ql-cache\/quicklatex.com-5292342c4d9d09085f9b7de4f4424eed_l3.svg\" height=\"21\" width=\"232\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#100;&#111;&#116;&#123;&#120;&#125;&#95;&#50;&#32;&#61;&#32;&#108;&#95;&#49;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#100;&#111;&#116;&#123;&#92;&#116;&#104;&#101;&#116;&#97;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#99;&#111;&#115;&#32;&#92;&#116;&#104;&#101;&#116;&#97;&#32;&#43;&#32;&#108;&#95;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#100;&#111;&#116;&#123;&#92;&#112;&#115;&#105;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#99;&#111;&#115;&#32;&#92;&#112;&#115;&#105;&#32; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 21px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tults.com\/wp-content\/ql-cache\/quicklatex.com-591a5f8362612d1f105a73b638f3f3e8_l3.svg\" height=\"21\" width=\"231\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#100;&#111;&#116;&#123;&#121;&#125;&#95;&#50;&#32;&#61;&#32;&#108;&#95;&#49;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#100;&#111;&#116;&#123;&#92;&#116;&#104;&#101;&#116;&#97;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#115;&#105;&#110;&#32;&#92;&#116;&#104;&#101;&#116;&#97;&#32;&#43;&#32;&#108;&#95;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#100;&#111;&#116;&#123;&#92;&#112;&#115;&#105;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#115;&#105;&#110;&#32;&#92;&#112;&#115;&#105; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now we have our velocity and position functions, we need to find our lagrangian. The lagrangian is given by:<\/p>\n\n\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 12px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tults.com\/wp-content\/ql-cache\/quicklatex.com-6022924a35d3df7ef3f5e969041cb151_l3.svg\" height=\"12\" width=\"84\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#109;&#97;&#116;&#104;&#99;&#97;&#108;&#123;&#76;&#125;&#32;&#61;&#32;&#84;&#32;&#45;&#32;&#86; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Where T is our Kinetic Energy, and V is our Potential Energy. We will use the classical kinetic energy formula as below:<\/p>\n\n\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 36px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tults.com\/wp-content\/ql-cache\/quicklatex.com-a987cb36ae16b27e2bcf9832c58ff27d_l3.svg\" height=\"36\" width=\"154\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#75;&#95;&#101;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#109;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#118;&#94;&#50;&#32;&#61;&#32;&#84; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And the formula for potential energy:<\/p>\n\n\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 14px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tults.com\/wp-content\/ql-cache\/quicklatex.com-7b2ff0a430d42a86a41f77647bf23922_l3.svg\" height=\"14\" width=\"119\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#80;&#95;&#101;&#32;&#61;&#32;&#109;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#104;&#32;&#61;&#32;&#86; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, plugging our variables into our energy equations and then into the lagrangian  we can see the following:<\/p>\n\n\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 36px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tults.com\/wp-content\/ql-cache\/quicklatex.com-f538763f7dd372279a8368e5647e2995_l3.svg\" height=\"36\" width=\"698\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#109;&#97;&#116;&#104;&#99;&#97;&#108;&#123;&#76;&#125;&#32;&#61;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#40;&#109;&#95;&#49;&#32;&#43;&#32;&#109;&#95;&#50;&#41;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#108;&#95;&#49;&#32;&#94;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#100;&#111;&#116;&#123;&#92;&#116;&#104;&#101;&#116;&#97;&#125;&#94;&#50;&#32;&#43;&#32;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#109;&#95;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#108;&#95;&#50;&#32;&#94;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#100;&#111;&#116;&#123;&#92;&#112;&#115;&#105;&#125;&#94;&#50;&#32;&#43;&#32;&#109;&#95;&#49;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#108;&#95;&#49;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#108;&#95;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#100;&#111;&#116;&#123;&#92;&#116;&#104;&#101;&#116;&#97;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#100;&#111;&#116;&#123;&#92;&#112;&#115;&#105;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#99;&#111;&#115;&#40;&#92;&#116;&#104;&#101;&#116;&#97;&#32;&#45;&#32;&#92;&#112;&#115;&#105;&#41;&#32;&#43;&#32;&#40;&#109;&#95;&#49;&#32;&#43;&#109;&#95;&#50;&#41;&#92;&#99;&#100;&#111;&#116;&#32;&#108;&#95;&#49;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#103;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#99;&#111;&#115;&#32;&#92;&#116;&#104;&#101;&#116;&#97;&#92;&#99;&#100;&#111;&#116;&#32;&#32;&#109;&#95;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#103;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#108;&#95;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#99;&#111;&#115;&#32;&#92;&#112;&#115;&#105; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now we come to what is possibly the most beautiful equation in all of physics, one that revolutionized the way that physics works in the real world, the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Euler%E2%80%93Lagrange_equation\">Euler Lagrange Equation<\/a>. It is considered to be so revolutionary that there is an entire branch of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Lagrangian_mechanics\">studying mechanics<\/a> revolving around applications of this equation. It is no understatement to say that it is <em>possibly<\/em> my favourite equation in the history of mathematics. So much so, that I stole this snazzy graphic below to show how much I like the euler lagrange equation.<\/p>\n\n\n\n<h1 class=\"ml1\">\n  <span class=\"text-wrapper\">\n    <span class=\"line line1\"><\/span>\n    <span class=\"letters\">\u2202L\/\u2202q - d\/dt(\u2202L\/\u2202q') = 0<\/span>\n    <span class=\"line line2\"><\/span>\n  <\/span>\n<\/h1>\n\n<script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/animejs\/2.0.2\/anime.min.js\"><\/script>\n\n<script>\n\/\/ Wrap every letter in a span\nvar textWrapper = document.querySelector('.ml1 .letters');\ntextWrapper.innerHTML = textWrapper.textContent.replace(\/\\S\/g, \"<span class='letter'>$&<\/span>\");\n\nanime.timeline({loop: true})\n  .add({\n    targets: '.ml1 .letter',\n    scale: [0.3,1],\n    opacity: [0,1],\n    translateZ: 0,\n    easing: \"easeOutExpo\",\n    duration: 600,\n    delay: (el, i) => 70 * (i+1)\n  }).add({\n    targets: '.ml1 .line',\n    scaleX: [0,1],\n    opacity: [0.5,1],\n    easing: \"easeOutExpo\",\n    duration: 700,\n    offset: '-=875',\n    delay: (el, i, l) => 80 * (l - i)\n  }).add({\n    targets: '.ml1',\n    opacity: 0,\n    duration: 1000,\n    easing: \"easeOutExpo\",\n    delay: 1000\n  });\n<\/script>\n\n\n\n<p class=\"wp-block-paragraph\">What a beautiful equation. So by applying the Euler-Lagrange equation to our formula, we get the following. <\/p>\n\n\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 22px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tults.com\/wp-content\/ql-cache\/quicklatex.com-454012c5d4ff2cdafa614c8a3e7726b9_l3.svg\" height=\"22\" width=\"582\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#40;&#109;&#95;&#49;&#32;&#43;&#32;&#109;&#95;&#50;&#41;&#92;&#99;&#100;&#111;&#116;&#32;&#108;&#95;&#49;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#100;&#100;&#111;&#116;&#123;&#92;&#112;&#115;&#105;&#125;&#32;&#43;&#32;&#109;&#95;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#108;&#95;&#50;&#32;&#32;&#92;&#99;&#100;&#111;&#116;&#92;&#100;&#100;&#111;&#116;&#123;&#92;&#112;&#115;&#105;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#99;&#111;&#115;&#40;&#92;&#116;&#104;&#101;&#116;&#97;&#32;&#45;&#32;&#92;&#112;&#115;&#105;&#41;&#32;&#43;&#32;&#109;&#95;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#108;&#95;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#100;&#111;&#116;&#123;&#92;&#116;&#104;&#101;&#116;&#97;&#125;&#94;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#115;&#105;&#110;&#40;&#92;&#116;&#104;&#101;&#116;&#97;&#32;&#45;&#32;&#92;&#112;&#115;&#105;&#41;&#32;&#43;&#32;&#40;&#109;&#95;&#49;&#32;&#43;&#109;&#95;&#50;&#41;&#92;&#99;&#100;&#111;&#116;&#32;&#103;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#116;&#104;&#101;&#116;&#97;&#32;&#61;&#32;&#48; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 22px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tults.com\/wp-content\/ql-cache\/quicklatex.com-7587bd680b61d96e1a4ab7a634f3a4f1_l3.svg\" height=\"22\" width=\"583\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#109;&#95;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#108;&#95;&#50;&#92;&#99;&#100;&#111;&#116;&#32;&#32;&#92;&#100;&#100;&#111;&#116;&#123;&#92;&#112;&#115;&#105;&#125;&#32;&#43;&#32;&#109;&#95;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#108;&#95;&#49;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#100;&#100;&#111;&#116;&#123;&#92;&#116;&#104;&#101;&#116;&#97;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#99;&#111;&#115;&#40;&#92;&#116;&#104;&#101;&#116;&#97;&#32;&#45;&#32;&#92;&#112;&#115;&#105;&#41;&#32;&#45;&#32;&#109;&#95;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#108;&#95;&#49;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#100;&#111;&#116;&#123;&#92;&#116;&#104;&#101;&#116;&#97;&#125;&#94;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#115;&#105;&#110;&#40;&#92;&#116;&#104;&#101;&#116;&#97;&#32;&#45;&#32;&#92;&#112;&#115;&#105;&#41;&#32;&#43;&#32;&#109;&#95;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#103;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#115;&#105;&#110;&#32;&#92;&#112;&#115;&#105;&#32;&#61;&#32;&#48; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Right, now we have our equations of motion, time to build our pendulum. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The pendulum<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">See our pretty pendulum, actually moving below<\/p>\n\n\n\n<canvas id=\"Pendulum\" style=\"border:1px solid #000000;\" width=\"300\" height=\"300\"><\/canvas>\n<script>\nvar time = 0;\nvar gravity = 20;\n\nlet theta = 45*Math.PI\/180;\nlet theta_hist = [];\nlet theta_dot = 0;\nlet theta_dot_hist = [];\nlet theta_dub = 0;\nlet theta_dub_hist = [];\nvar mass1 = 10;\nvar length1 = 90;\n\nlet psi = 120*Math.PI\/180;\nlet psi_hist = [];\nlet psi_dot = 0;\nlet psi_dot_hist = [];\nlet psi_dub = 0;\nlet psi_dub_hist = [];\nvar mass2 = 5;\nvar length2 = 55;\nvar dt = 0.05;\n\nfunction updateHist(){\ntheta_hist.unshift(theta);\ntheta_dot_hist.unshift(theta_dot);\ntheta_dub_hist.unshift(theta_dub);\n\npsi_hist.unshift(psi);\npsi_dot_hist.unshift(psi_dot);\npsi_dub_hist.unshift(psi_dub);\n\nif(theta_hist.length > 260)\n{\ntheta_hist.pop();\ntheta_dot_hist.pop();\ntheta_dub_hist.pop();\npsi_hist.pop();\npsi_dub_hist.pop();\npsi_dot_hist.pop();\n}\n\n}\n\nfunction updateValues(){\nvar prev_theta = theta;\nvar prev_psi = psi;\nvar prev_theta_dot = theta_dot;\nvar prev_psi_dot = psi_dot;\n\ntheta_dub = (-1*gravity*(2*mass1+mass2)*Math.sin(theta)-mass2*gravity*Math.sin(theta-2*psi)-2*Math.sin(theta-psi)*mass2*(psi_dot*psi_dot*length2+theta_dot*theta_dot*length1*Math.cos(theta-psi)))\/(length1*(2*mass1 + mass2 -mass2*Math.cos(2*theta-2*psi)));\npsi_dub = (2*Math.sin(theta-psi)*(theta_dub*theta_dub*length1*(mass1+mass2)+gravity*(mass1+mass2)*Math.cos(theta)+psi_dub*psi_dub*length2*mass2*Math.cos(theta-psi)))\/(length2*(2*mass1+mass2-mass2*Math.cos(2*theta-2*psi)));\n\ntheta_dot = theta_dot + theta_dub*dt;\ntheta = theta+theta_dot*dt;\n\npsi_dot = psi_dot + psi_dub*dt;\npsi = psi + psi_dot*dt;\n\nif(theta > 2*Math.PI){\ntheta = theta-2*Math.PI;\n}\nif(psi > 2*Math.PI){\npsi = psi-2*Math.PI;\n}\nif(theta < -2*Math.PI){\ntheta = theta+2*Math.PI;\n}\nif(psi < -2*Math.PI){\npsi = psi+2*Math.PI;\n}\n\nupdateHist();\n\n}\n\nfunction init(){\nwindow.requestAnimationFrame(draw);\n}\n\nfunction draw(){\nvar c = document.getElementById(\"Pendulum\");\nc.parentElement.style.textAlign = \"center\";\nvar ctx = c.getContext(\"2d\");\n\/\/Clear Screen\nctx.clearRect(0, 0, 300, 300);\n\/\/Draw fulcrum\nctx.beginPath();\nctx.arc(150, 50, 5, 0, 2 * Math.PI);\nctx.fillStyle = '#808080';\nctx.fill();\nctx.stroke();\n\nvar x1 = length1*Math.sin(theta) + 150;\nvar y1 = length1*Math.cos(theta) + 50;\n\nvar x2 = length2*Math.sin(psi) + x1;\nvar y2 = length2*Math.cos(psi) + y1;\n\n\/\/Draw tail\nfor(var curVal = 0; curVal < theta_hist.length\/3; curVal++){\n\nctx.globalAlpha = ((theta_hist.length\/3)-curVal)\/(theta_hist.length\/3)\nvar cTheta = theta_hist[curVal];\nvar cPsi = psi_hist[curVal];\nvar cThetax = length1*Math.sin(cTheta) + 150;\nvar cThetay = length1*Math.cos(cTheta) + 50;\nvar cPsix = length2*Math.sin(cPsi) + cThetax;\nvar cPsiy = length2*Math.cos(cPsi) + cThetay;\n\nctx.beginPath();\nctx.arc(cThetax, cThetay, 3, 0, 2*Math.PI);\nctx.fillStyle = '#FFDFBF';\nctx.fill();\n\nctx.beginPath();\nctx.arc(cPsix, cPsiy, 3, 0, 2*Math.PI);\nctx.fillStyle = '#CCB7E5';\nctx.fill();\n\n}\nctx.globalAlpha = 1;\n\n\/\/Draw arms\nctx.beginPath();\nctx.moveTo(150, 50);\nctx.lineTo(x1, y1);\nctx.stroke();\n\nctx.beginPath();\nctx.moveTo(x1, y1);\nctx.lineTo(x2, y2);\nctx.stroke();\n\n\/\/Add Balls\nctx.beginPath();\nctx.arc(x1, y1, 10, 0, 2*Math.PI);\nctx.fillStyle = '#FFDFBF';\nctx.fill();\nctx.stroke();\n\nctx.beginPath();\nctx.arc(x2, y2, 10, 0, 2*Math.PI);\nctx.fillStyle = '#CCB7E5';\nctx.fill();\nctx.stroke();\n\n\/\/update values\nupdateValues();\n\n\/\/Recurse\nwindow.requestAnimationFrame(draw);\n}\n\ninit();\n\n<\/script>\n\n\n\n<p class=\"wp-block-paragraph\">There is every intention of adding variables here to change conditions, but I am not interested in adding them right now. Maybe at a later date :). <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Graphing<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The real reason to do any science is to get some graphs. So, I have made a bunch of graphs to plot the velocity, acceleration and angle of the pendulum below.<\/p>\n\n\n\n<canvas id=\"Graph1\" style=\"border:1px solid #000000;\" width=\"300\" height=\"300\"><\/canvas>\n<script>\nfunction initG1(){\nwindow.requestAnimationFrame(drawG1);\n}\n\nfunction drawG1(){\nvar c = document.getElementById(\"Graph1\");\nc.parentElement.style.textAlign = \"center\";\nvar ctx = c.getContext(\"2d\");\n\/\/make values clean\n\/\/Clear Screen\nctx.clearRect(0, 0, 300, 300);\n\/\/ All good graphs have titles\nctx.beginPath();\nctx.fillStyle = '#000000';\nctx.fillText(\"Angle Graph\", 130, 20);\nctx.stroke();\n\n\/\/Draw axis\nctx.beginPath();\nctx.moveTo(20, 40);\nctx.lineTo(20, 280);\nctx.stroke();\n\nctx.beginPath();\nctx.moveTo(20, 160);\nctx.lineTo(280, 160);\nctx.stroke();\n\nfor(var curVal = 0; curVal < theta_hist.length; curVal++)\n{\nvar cTheta = theta_hist[curVal];\nvar cPsi = psi_hist[curVal];\nctx.beginPath();\nctx.arc(20+curVal, 160+50*cTheta, 3, 0, 2*Math.PI);\nctx.fillStyle = '#FFDFBF';\nctx.fill();\n\nctx.beginPath();\nctx.arc(20+curVal, 160+50*cPsi, 3, 0, 2*Math.PI);\nctx.fillStyle = '#CCB7E5';\nctx.fill()\n}\n\n\/\/Recurse\nwindow.requestAnimationFrame(drawG1);\n}\n\ninitG1();\n\n<\/script>\n\n\n\n<p class=\"wp-block-paragraph\">Adding to this, we would also like to graph the velocity, so, consider that graphed below. <\/p>\n\n\n\n<canvas id=\"Graph2\" style=\"border:1px solid #000000;\" width=\"300\" height=\"300\"><\/canvas>\n<script>\nfunction initG2(){\nwindow.requestAnimationFrame(drawG2);\n}\n\nfunction drawG2(){\nvar c = document.getElementById(\"Graph2\");\nc.parentElement.style.textAlign = \"center\";\nvar ctx = c.getContext(\"2d\");\n\/\/make values clean\n\/\/Clear Screen\nctx.clearRect(0, 0, 300, 300);\n\/\/ All good graphs have titles\nctx.beginPath();\nctx.fillStyle = '#000000';\nctx.fillText(\"Velocity Graph\", 130, 20);\nctx.stroke();\n\n\/\/Draw axis\nctx.beginPath();\nctx.moveTo(20, 40);\nctx.lineTo(20, 280);\nctx.stroke();\n\nctx.beginPath();\nctx.moveTo(20, 160);\nctx.lineTo(280, 160);\nctx.stroke();\n\nfor(var curVal = 0; curVal < theta_hist.length; curVal++)\n{\nvar cTheta = theta_dot_hist[curVal];\nvar cPsi = psi_dot_hist[curVal];\nctx.beginPath();\nctx.arc(20+curVal, 160+50*cTheta, 3, 0, 2*Math.PI);\nctx.fillStyle = '#FFDFBF';\nctx.fill();\n\nctx.beginPath();\nctx.arc(20+curVal, 160+50*cPsi, 3, 0, 2*Math.PI);\nctx.fillStyle = '#CCB7E5';\nctx.fill()\n}\n\n\/\/Recurse\nwindow.requestAnimationFrame(drawG2);\n}\n\ninitG2();\n\n<\/script>\n\n\n\n<p class=\"wp-block-paragraph\">So, not only can we see our beautiful pendulum swinging too and fro, exhibiting chaos, we can also plot its angle, and velocity against time. If we wanted too, we could go more in depth for that, but not much of it is too fun to put on a website, so I have attached the report that goes VERY in depth into chaos analysis below. If you have any questions, queries or concerns, or wish to reach out to me to discuss this project, feel free to email me on erik@tults.com.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/tults.com\/wp-content\/uploads\/2021\/12\/A_Chaotic_Analysis_of_the_Inertial_Double_Pendulum.pdf\">The report<\/a><\/h3>\n","protected":false},"excerpt":{"rendered":"<p>Synopsis: The pendulum project was one that I undertook in university to create an inertial double pendulum simulator. The goal was to understand chaos, and to understand how chaos adapts and evolves in a controlled environment. On this page, we talk about point mass pendulum (where the center of gravity is located at the veryContinue reading &rarr;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":171,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-216","page","type-page","status-publish","hentry","no-thumb"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tults.com\/index.php\/wp-json\/wp\/v2\/pages\/216","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tults.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/tults.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/tults.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tults.com\/index.php\/wp-json\/wp\/v2\/comments?post=216"}],"version-history":[{"count":214,"href":"https:\/\/tults.com\/index.php\/wp-json\/wp\/v2\/pages\/216\/revisions"}],"predecessor-version":[{"id":810,"href":"https:\/\/tults.com\/index.php\/wp-json\/wp\/v2\/pages\/216\/revisions\/810"}],"up":[{"embeddable":true,"href":"https:\/\/tults.com\/index.php\/wp-json\/wp\/v2\/pages\/171"}],"wp:attachment":[{"href":"https:\/\/tults.com\/index.php\/wp-json\/wp\/v2\/media?parent=216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}