## coupled oscillators

it’s time for a long post on coupled oscillators. i love teaching this in dynamical systems class. it all starts with a pair of identical or near-identical systems expressing periodic behavior. let’s say we have two pendula, and we let them go. what happens?

well, they just do their thing. same mass; same length; but because of the different initial conditions, their motions are distinct. now here’s the idea (going back at least to huygens): if we allow each to slightly influence the other — say through small oscillations transmitted through the rod by which they hang — then the pendula become synchronized, even though they have different energies to begin with. let’s take a look.

this is cool! i wonder if it works in more generality? the way i teach it in class is through a spinner — an abstract agent with configuration space a circle and whose dynamics are simple, linear escalation of angle. if you start with two such spinners having the same natural frequency but different phase, then, like the uncoupled pendula above, they will remain out of phase. however, if you let each influence the other very slightly, then, over time, they converge to synchronized evolution, like so:

that’s simple enough, and easy to analyze. you can even say what the rate of convergence is, based on linearization of the dynamical system about the equilibrium of phase zero. but then come all the questions… what happens if you have more than two spinners? does it matter how you network their influences? well…

nine identical spinners are given the same initial conditions. the system on the right has all-to-all coupling: everyone influences everyone. on the left is a ring topology, with nearest-neighbor coupling. the all-to-all network topology converges rapidly to a synchronized state. the ring topology converges too, but more slowly, and it is “off phase” a little bit from the all-to-all, even though they all started at the same place.

so, that’s fun. but that’s not all that can happen. in the all-to-all case, it seems as though it will always converge to a synchronized state. (is that so? hmmmm…). this is not the case in the ring topology; with a bit of luck, you can happen upon an initial condition that gives non-synchronized behavior. what is it?

ah, it’s the wave. the reason this is possible is because of the topology of the network — like, literally. the circular topology means that the angular data over the base has a cohomology class in H^1(S^1)=Z — otherwise known as a winding number. this is why you don’t get this phenomena in the all-to-all topology — no holes (upon completion to a flag complex). i’ve used the cohomology class of a networked S^1-valued dynamical system to automate sleep-wake cycles for sensor networks in building interiors, for example: very useful stuff.

well, that escalated quickly.

let’s go back to thinking about synchronization. what happens if you have a larger, less homogeneous network? here’s an example:

you can almost see the different eigenvalues of the graph laplacian. in plainer terms, the higher the local connectivity, the faster the network synchronizes.

but what happens if the network changes over time, as it does for flocks of birds, schools of fish, & crowds of people? ah, that is where a lot of modern research comes in to play.

## visualizing 1-d flows

visualization is so central to dynamical systems. one great place to get started is with 1-d continuous-time autonomous systems: ODEs of the form dx/dt=f(x). there are a lot of ways to illustrate such systems. one is to plot the solution x(t) for an initial condition x(0). that’s ok, but it’s even better to look at the flow, where you look at all initial conditions at once and let them evolve. but it does not end there. i like to supress time altogether, and plot x versus dx/dt. this makes it possible to visualize the dynamics as that of a vector field on the x-axis. you can see all of these perspectives illustrated below:

## the bouncing ball…

one of the classic examples of a simple discrete-time dynamical system comes from a bouncing ball. if you let a ball go above a table, then, assuming everything is perfectly flat, etc., a simple model for the dynamics is x(n+1)=r x(n), where 0<r<1 is the coefficient of restitution and x(n) is the height of the n-th bounce. very well: that has a simple explicit solution that ends with the ball coming to rest.

but what happens if we give the table a sinusoidal oscillation? let’s take a look…

this is likewise modeled as a dynamical system, but no longer 1-dimensional — it is a 2-dimensional discrete-time dynamical system. without going into a derivation, let me say that the two variables are related to the time-between-bounces and the velocity-upon-impact. indexed by n, the bounce number, this leads to complicated behaviors. of course, everything depends as well on parameters, such as ball size, mass, frequency of oscillation, and initial condition, as you can see from the following simulation.

this system goes straight to the heart of why 2-d discrete-time dynamics can be chaotic. we won’t go into details on this quite yet… but let me say that this is one of the four chaotic dynamical systems that appears in the beginning of the seminal text of guckenheimer & holmes. phil homles (my phd advisor) studied this system in 1982. this simulation is a bit easier to “see” that the static picture appearing in that classic text, but the picture painted by the mathematics is every bit as beautiful & illustrative.

## staircase diagrams

i think the best way to begin learning about discrete-time dynamical systems is with the following well-known example. take a calculator; set it to radians; type in a random number; then hit the cosine button over & over. what happens is convvergence to a stable equilibrium. the way the covergence happens is through over- then under-shooting. why? let’s take a look…

for discrete-time 1-d dynamics, the best way to visualize is via a staircase diagram, in which you plot x_{n+1} versus x_n, where x_{n+1} = f(x_n). this allows you to investigate what happens for arbitrary functions f.

if you look closely, you can see the differences between stable and unstable equilibria. of course, more interesting things can happen, but we’ll talk about that later…

## 1-d maps

dynamical systems come in two flavors — continuous and discrete time. we’ll be covering lots of interesting examples in both settings. but for the moment, it’s worth noting that 1-d discrete-time systems ( or “maps” ) provide a microcosm of what dynamical systems entails.

illustrated below is a staircase diagram of the logistic map, defined by x(n+1) = f(x(n)), where f is a quadratic of the form f(x) = a x ( 1 – x ). as you change the value of the parameter a>0 and the initial condition x(0), then poltting x(n+1) versus x(n) is illuminating. you can see stable and unstable equilibria, periodic orbits of various types, and everything changing. how to make sense of it all? that’s what dynamical systems covers.

## joint types, pendula, & configurations

one of the things i loved most in my engineering undergraduate education was learning kinematics — all kinds of cool mechanisms. the pendula that we’ve been looking at have some interesting joints. the planar pendulum has a simple hinge joint, easily built using a high-quality low-friction bearing. the spherical pendulum, on the other hand, has a ball-and-socket joint, which in practice could be effected by a spherical bearing. these are beautiful mechanisms that use lubrication and/or tiny ball bearings to get a nice clean swivel.

but this is not the only joint type with multiple degrees of freedom. consider the universal joint, built by fusing two transverse hinges, as illustrated below.

wouldn’t it be fun to simulate a double-pendulum with universal joints and compare it to the analogous system with spherical joints? what a good idea…

this is so much fun to play with… with the bottom views in particular, you sense that the universal joints give very different behavior than the spherical joints. the universals are more… jerky… constrainted. the spherical joints seem more free.

but are they? are they equivalent in some way? how would you tell? i like to think in terms of the configuration space of a joint (or system of joints). a universal joint has configuration space a 2-dimensional torus (one circle for each hinge joint). of course, this ignores physical constraints such as rigid bars colliding, but there you have it. the spherical joint, on the other hand, as a full SO(3) configuration space, which is three-dimensional, not 2-d like the universal. so, in one sense, this is why a spherical joint “feels” more free. it’s also the reason why a spherical joint cannot transmit torque the way that universal joints can. (universals — or rather pairs of them — are very helpful in automobiles to transmit power from the axles to the wheels…)

## the sublime spherical double pendulum

i like pendula in all forms as a way to visualize interesting dynamical systems. i’m most interest in the mathematics behind it all, but occasionally, i let my initial training in mechanical engineering get the best of me. this is one of those times.

consider what happens when you have a double-pendulum, but where the joints are spherical as opposed to planar (or “hinge”) in nature. this is really beautiful.

this can be a little difficult to visualize properly, since there is motion out of the plane of view. let’s take a look at the exacy same simulation, but from below…

ah… that’s a nice double pendulum!

## about creating graphics & video

“how do you make these?”
“what software do you use?”

i get asked this on a near-daily basis. usually, i ignore the question or, if feeling guilty, i may say “well, it would take a long time to explain it all, since it’s a really complicated process“. but that leaves people at best wondering and at worst aggressive. so, for the sake of giving people a link where they can get some answers, here it is.

tl; dr: you’re asking the wrong question.

when you ask “what software?” i imagine that you are looking for a magical package for matlab or python or mathematica that makes beautiful graphics. in this case, the short answer is “sorry, does not exist“. if you want to know how i make videos… well, it’s complicated.

1. it took me years of hard word to learn how to make what i make. you can see my progress, from 2010-2012 using a tablet pc (i loved my fujitusu!) to make the FLCT, to the coursera days of 2012-2013 using nothing but powerpoint to create some really fun animations. i’ve been learning steadily since the Calculus BLUE Project started in may 2015. i’m still not professional-quality, but i’m much better than i used to be. it may take you time to learn also.
2. i learned most of what i know through watching youtube videos, reading books, and following artists on social media. it only took a few months of input to get to the point where i can quickly tell the difference between the major graphics packages and rendering engines out there by glancing at the end product. if you want to make pro-quality graphics, you will need to use pro-quality software. that means spending money and time. if you don’t know what rendering engine was used, you don’t yet know enough to use it well.
3. more important than the software packages are the techniques of which design, animation, and compositing are key. i will tell you that i use a blend of powerpoint and adobe tools (AE/PP) to composite my calculus videos. it’s really hard to get those two to play nice together.
4. i will also tell you that i use a combination of coding (python/julia), game engines (for simulations) and 3-d modeling & rendering engines to build, animate, and simulate systems. that took several years to learn how to do this decently, and, i repeat, i am not at a professional level. i use a mix of different packages, none of which i will endorse (besides powerpoint, which holds a special place in my heart given the scorn it cheerfully endures from others).

so, what should you do if you want to make cool technical animations/videos?

1. start learning the basics of graphics, starting with perception and color. don’t forget to fill in with good design principles, especially fonts. math/science is plagued with ugly fonts, courtesy of TeX & LaTeX, the tools that saved 20th c. math publishing and doomed 21st c. math publishing to an outdated ugly hell.
2. pick some simple playground where you can practice doing graphics. my favorite in this category is the processing language, since it is free, fun, and expressive enough to keep you busy. adobe after effects is less programmable, but very powerful 2+1-dimensional software. for fully 3-d, check out the list of available options on wikipedia. pick something with a free version & start learning.
3. the best way to get good is to produce on a schedule. for a few years. if you think that there’s some magic software that will easily give you good animations, you are misled.

if you’re satisfied, please stop here.

if you want to know more, i’m afraid i’m going to have to be more direct.

\begin{rant}
i teach mathematics and its applications. i do not teach graphics and i definitely don’t teach “how to use software X to make cool thing Y”. what i care about is the mathematics. you might think it’s flattering to ask me “hey, what software?” when i post a video about math. it is not, in a similar way that it is not flattering to ask a mathematician about where she gets her fine shoes or wonderful suits. that is entirely incidental to the professional task at hand, and to focus on the external show as opposed to the intellectual craft is an (unintentional but not unhurtful) insult.

on a related note, please also don’t demand source files, as they will do you no good without commitment to training.
\end{rant}

## a spherical pendulum

all of the pendula below are “planar” or have “hinge” joints that constrict motion to a plane. if we replace said hinge joints with a “ball-and-socket” joint, then we have what one calls a spherical pendulum. these have an increased range of motion and lead to some lovely behavior when viewing multiple initial conditions.

you might rightly complain that these “spherical” pendula do not take advantage of their increased degrees of freedom. if you look carefully, each pendulum above moves within a single plane. this is a consequence of there being no initial velocity.

let’s change that, and see what motion ensues…

## pendula without rods

so what happens if we build a multi-pendulum with structures other than rigid rods? using hoops (solid tori) is especially mesmerizing, and leads one to believe that the dynamics is very different that the rigid-rod case…

a more careful analysis would show that using rings is equivalent to using rods, as long as you are careful about the equivalent mass (becuase of moment of inertia, the mass of the solid rod and that of the corresponding ring are not the same).

of course, this is be taken to foolish extremes. i do not recommend that you build the following system: