Euler’s Method: Simulating the Future
Act 1: Leonhard Euler (1707 - 1783)
While Galileo, Newton and others before them handed us the keys to motion, and mathematical foundations like Calculus discovered around this period [1] helped in developing elegant and powerful solutions for simple systems like pendulums, most of the systems are not that simple. Any attempt to solve complex systems, such as the movement of car wheels when the engine forces the transmission to move them using analytical calculus, would be like using nail clippers to excavate a mile-long tunnel.
Calculus quickly turns into a wild jungle.
Born in 1707 in Switzerland, Euler was a maths wizard—no less "The King of Mathematics" [2]. He is hailed as such, and many people are intimidated by the title. He worked in Berlin and St. Petersburg, went blind later in life (but kept calculating in his head!) [3], and left us with so many formulas that people still rediscover his works.
Euler could say about many current works that are still relevant, Been there, done that. Just think about it—over 250 years later, and his works are still relevant.
But first, let’s remember where we left off with the pendulum. Newton’s laws gave us this classic (and slightly intimidating) equation:
This little beauty tells us how a pendulum swings, but it’s a non-linear beast—tricky to solve analytically exactly unless you’re a fan of elliptic functions [4].
Fun fact: elliptic functions pop up in the proof of Fermat's Last Theorem [5]. A theorem that Euler could not prove, well add Gauss, Lagrange, Cauchy and several other greats to that list. So let us not step into that jungle yet. For small swings, however, we can cheat a bit and say as we have seen before.
But what if we want to handle the real thing and not approximate, we better let the computers do these kind of work and tell them how to though algorithms?
Act 2: Numerical Algorithm: Euler's Method
We break out the numerical integration toolkit [6]. Instead of leaping straight to the future, we tiptoe there one tiny step at a time.
Let’s talk about what we want from the computer at the end to learn or predict/simulate a swinging pendulum. Our equation from before,
is a second-order differential equation. That means, to predict the future, we need to know not just where the pendulum starts (its initial angle ), but also how fast it’s moving at the start (its initial angular velocity ). Two pieces of information for two derivatives—fair’s fair!
Now we need some mathematical gymnastics before we can easily use Euler's method, because Euler's method by definition works with first-order equations. Let's move to the next Act.
Act 3: State Space .𖥔 ݁ ˖ִ🛸༄˖°.
Without actually going too deep into this here [7], I will convince you that for the equation of motion for the pendulum, which is a second-derivative in time, you need two time-dependent variables to track the system and here we can say that all we need are:
- Angular-Position ()
- Velocity ()
Now let us morph the equation for pendulum motion below and we start numbering the equations now:
into these two equations:
Take some time with it and you will find that equations 2 and 3 together are equivalent to equation 1. Now we have written the pendulum equation that exclusively depends on the two state-space variables we defined earlier and their time derivatives. We are now ready for Euler's method.
Before we proceed, let's look a little closer. When you inspect equations (2) and (3), try plugging in the initial values of the state-space variables at time . We have:
- Initial condition - 2, -> initial velocity is zero
- Initial condition - 1 -> initial position is
Now try to plug in future times—you cannot get the values because you don't have the information. This is where the cleverly devised information-chaining method introduced by Euler helps us march through time and track complete information about the system. We will see in the next section, finally we are so close to the predictable nature we so desire.
Act 4: Time-Marching
Let us say is function of time like position of the "Bob". Then, Euler's method says [8]:
where is the step size for marching in time. If you want to predict the system at 0.1 seconds after , then seconds.
Now for that is the position of the "Bob" we can write,
and for velocity we can write, just like equation 6 as,
Now, it should be apparent to a keen eye that the way we wrote equations 2 and 3 has derivatives on the left-hand side. These can be directly used to replace the derivative terms in equations 7 and 8, making them specific to the pendulum system. Right now, equations 7 and 8 are just general expressions for Euler's method written in terms of two different state-space variables—they contain no information about the pendulum. Let's fix that:
and for velocity we can write, just like equation 6 as,
With equations 8 and 9 above, you can start from , where all the quantities on the right are known, and estimate the state space at seconds, and so on.
Predictibility is mine! And the Clockwork of the world is achieved.!
Act 5: Demystify with Some Hand Calculations
Let's use equations 8 and 9 and march through time for a few steps to demonstrate how this works before asking the computer to scale up the calculations!
Suppose:
- m/s², m
- s
- Initial angle rad (about 11°)
- Initial angular velocity
Step 1 (at ):
Using Equation (9):
Using Equation (8):
Time advances: s
Step 2 (at ):
Using Equation (9) with updated :
Using Equation (8) with current :
Time advances: s
Step 3 (at ):
Using Equation (9) with updated :
Using Equation (8) with current :
Time advances: s
Act 6: Finale - Analytical vs Euler Simulation
Below, you can pit the true (analytical, small angle) solution against the Euler approximation. Crank up the time step (dt) or the initial angle and watch how Euler’s method starts to wander off the path. It’s a bit like watching a friend try to follow directions after one too many cups of coffee:
Pendulum: Euler vs Analytical
Black: Euler’s method | Blue: Analytical (small angle)
Try increasing dt or the initial angle to see how Euler’s method diverges from the true solution.
Do you think predictability is still fully within our grasp? You can see that after some time, we start predicting the wrong state of the system. Are there any saviors now?
Quiz: Euler’s Method Limitations
Euler’s Method Quiz
References
-
Newton, I. & Leibniz, G.W. The priority dispute is well-documented in: Hall, A.R. (1980). Philosophers at War: The Quarrel between Newton and Leibniz. Cambridge University Press. ISBN 978-0-521-22732-2.
-
Dunham, W. (1999). Euler: The Master of Us All. Mathematical Association of America. ISBN 978-0-88385-328-3. MAA Publication
-
Calinger, R. (2016). Leonhard Euler: Mathematical Genius in the Enlightenment. Princeton University Press. pp. 456-470, on Euler's blindness. ISBN 978-0-691-11927-4.
-
Lawden, D.F. (1989). Elliptic Functions and Applications. Springer-Verlag. Chapter 5: "The Simple Pendulum." ISBN 978-0-387-96965-5.
-
Wiles, A. (1995). "Modular elliptic curves and Fermat's Last Theorem." Annals of Mathematics, 141(3), pp. 443-551. JSTOR
-
Euler, L. (1768). Institutionum calculi integralis, Vol. 1. St. Petersburg Imperial Academy. The foundational work where numerical methods for differential equations appear. Euler Archive
-
Arnold, V.I. (1989). Mathematical Methods of Classical Mechanics, 2nd ed. Springer-Verlag. Chapter 1: "Experimental Facts" (introduces phase space). ISBN 978-0-387-96890-0.
-
Euler, L. (1768). Institutionum calculi integralis, Vol. 1, Section 650. The explicit forward difference method: . Euler Archive