Swift in Space – The N-Body Problem

updated 5 months ago; latest suggestion 5 months ago


The N Body Problem is a computationally complex problem that we use to predict how planets and galaxies – and everything in between – move through space. I’ll show you some interesting ways to calculate it, and we’ll have a look at what to do, should you find yourself in a space ship’s pilot seat.


The N-Body Problem is one of those famously hard to solve problems in computer science. It describes the movement and interactions of n bodies in space (where n is usually >= 3). You need a lot of computational power to passably approximate the gravitational influences a group of celestial bodies exert on each other. Can we explore that in Swift?

I’ll give a brief overview of the history of trying to predict the motion of the moon, sun and the visible stars, and then we’ll dive deep into the original N-Body Problem, followed by creative ways to reduce the amount of calculation needed and still get a reasonable approximation. Doing this, we can see how to tackle some complex mathematic and algorithmic problems easily using Swift, and also delve into how to estimate the complexity of an algorithm.

If you’re a beginner or even very early in your career as a developer, you are going to get a first impression of efficient algorithms and complex data structures, and how to measure complexity using Big O notation. If you’re more advanced, you’ll be treated to a hopefully interesting way of implementing the Barnes-Hutt-algorithm, and some space nerdery.

Once we have all the pieces in place, let’s play with some orbits. We’ll see how orbits actually behave, as opposed to what the untrained mind would expect. We can use our new algorithms to try out some manoeuvres often used by real space craft and help you be prepared for when that call from ESA or NASA finally comes, and you’ll be invited to work on Swift In Space!


  • The proposal author responds 5 months ago

    Thanks for your comment. I've held a version of this talk in a time slot of 40 minutes before. From that talk, I have a good idea of which parts are slightly less important and/or repetitive, so I'm confident I can cut it down to 30 minutes without losing too much of substance. (The proposal page said 30 minutes + 10 minutes Q&A, correct?)

  • 2fd5585092316e178382abb98bc00bb40ee9162e?size=100x100 2fd5585092316e178382abb98bc00bb40ee9162e suggests 5 months ago

    Wow! This sounds like an amazing talk. I read The Three Body Problem by Liu Cixin last year and thought about how one could approximate it in software as well. My only worry is that there is a lot of stuff to cover in 25mins. Besides introducing the audience to the theoretical background of the problem, I'd guess you'd also tell us about the basics of numerical estimation and then followed by Swift implementation details. Sounds like a semester full of stuff in 25mins to me.