a Mini Dive into Butterfly Effect
Heard of the “Butterfly Effect” yet? The butter fly effect is the idea that the tiny causes, like a flay of a butter fly’s wings in Brazil, can have huge effects, like setting off a tornado in Texas. Now that idea comes straight from the title of a scientific paper published nearly ~50 years ago and perhaps more than any other recent scientific concept, it has captured the public imagination. I mean on IMDB there is not one but many different movies, TV episodes, and short films with, not to mention prominent references in movies like the Jurassic Park, or the memes. Oh the memes!
Yeah….anyways, I think the reason people are so fascinated by the butterfly effect is, because it gets at a fundamental question, Which is: How well can we predict the future?
If you go back to the late 1600s, after Isaac Newton had come up with his laws of motion and universal gravitation, everything seemed predictable. To elaborate, we could explain the motions of all the planets and moons, through we could predict eclipses and the appearances of comets with pinpoint accuracy centuries in advance. In some sense the state or the future is already fixed, we just have to wait for it to manifest itself.
Now let me introduce you to the father of mordern chaos, Edward Lorenz. The old boring chaos really became popular in the 1960s, when meteorologist Dr. Lorenz tried to make a basic computer simulation of the Earth’s atmosphere. He had 12 equations and 12 variables, things like temperature, pressure, humidity and so on and the computer would print out each time step as a row of 12 numbers so you could watch how they evolved over time.
Now the breakthrough came when Dr. Lorenz wanted to redo a run but as a shortcut he entered the numbers from halfway through a previous printout and then he set the computer calculating, and when he came back and saw the results, he discovered that new run followed the old one for a short while but then it divergedand pretty soon it was describing a totally different state of the atmosphere. The real reason for the difference came down to the fact that printer rounded to three decimal places whereas the computer calculated with six. So when he entered those initial conditions, the difference of less than one part in a thousand created totally different weather just a short time into the future. Furthermore Dr. Lorenz tried simplifying his equations and then simplifying them some more, down to just three equations and three variables:
or in R code:
# Specify the wiki equations
lorenz_equations <- function(dt, state, parameters) {
with(as.list(c(state, parameters)), {
dx <- sigma * (y - x)
dy <- x * (rho - z) - y
dz <- x * y - beta * z
list(c(dx, dy, dz))
})
}
# Solve with initial condition
lorenz_solve <- function(y, dt, params) {
as.data.frame(
deSolve::ode(y = y, times = dt,
func = lorenz_equations,
parms = params,
method = "ode45")
)
}
# Specify constants which came directly from Wiki
constants <- c(sigma = 10, beta = 8/3, rho = 28)
Dr. Lorenz’s system displayed a sensitive dependence on initial conditions (which is also the foundation of the Differential Equations).For my approach I picked same initial conditions which were listed in the Wikipedia Page.
Now since Lorenz was working with three variables, we can plot the phase space of his system in 3D. We can pick any point as our initial state and watch how it evolves. I picked for the current state (2,3,4)
and (2,3,4.1)
for the future state. We can pick any point as our initial state and watch how it evolves:
# Times over which the equations are numerically solved
times <- seq(0, 25, 0.01)
# Initial conditions, in the order x, y, z vectors
state <- c(x = 2, y = 3, z = 4)
state_next <- c(x = 2, y = 3, z = 4.1)
# Solve the diffrential equations
solution_a <- lorenz_solve(state, times, constants)
solution_b <- lorenz_solve(state_next, times, constants)
solution_a$initialization <- "(2,3,4)"
solution_b$initialization <- "(2,3,4.1)"
Anyhow, let’s look at the plot of the Lorenz’s equations. This coincidentally, looks a bit like a butterfly:
Does our point move toward a fixed attractor (an attractor loosely speaking, is a stacking moment upon moment which reveals the little graph/path & offers us some insight of the dynamical systems, i.e. the wing is an attractor in the plot above)? In truth, our system will never revisit the same exact state again (however since this .gif you see above is saved with a state, over time, you will see points repeat). This is sensitive dependence on initial conditions in action. This system is chaotic, so any difference in initial conditions, no matter how tiny, will be amplified to a totally different final state.
Imagine, if we start with a whole bunch of different initial conditions and observe them evolve, initially the motion is messy as you might be able to see it in your head. However, like above, soon all the points have moved towards or onto an object in an attractor. Again, all the paths traced out here never cross and they never connect to form a loop. If they did then they would continue on that loop forever and the behavior would be periodic and predictable, so each path in the plot is actually an infinite curve in a finite space. But how is that possible? Fractals!!!
Finally, the science behind the butterfly effect also reveals a deep and beautiful structure underlying the dynamics. In the case of Lorenz’s equations, they take the shape of a butterfly. So how well can we predict the future? Not very well at all. The further into the future you try to predict the harder it becomes and past a certain point, predictions are no better than guesses.
I hope this was an enjoyable read for you. If you would like to see the source code, you can get it by going here. And if you would like to read more, feel free to read from this Wikipedia page. Stay home and please stay safe from CCP-Virus!
NOTE: Thank you very much for reading! If you discover any mistakes or want to offer any feedback, please feel free to email me.