## A mathematical glimpse into spherical harmonics

### The story of Joseph Fourier (1768-1830)

If you’ve been involved in physics or mathematics at some point in your life, you probably heard of a famous scientist by the name of Jean-Baptiste Joseph Fourier. Born in France in 1768, he lived in a very fertile time for French Science. He saw the creation of the prestigious « Ecole Polytechnique » and interacted with fellow contemporaries such as Gaspard Monge, Joseph-Louis Lagrange, Pierre-Simon de Laplace, Siméon Denis Poisson, or Adrien-Marie Legendre.

**Joseph Fourier**

In 1798, Fourier was asked by Napoleon to accompany him as a scientific adviser on his Egyptian expedition. After a few years spent as an adventurer in the faraway land, he came back to France in 1802 and was appointed by Napoleon Prefect of Isère, in Grenoble, a city in the French Alps. Fourier accomplished his duties as a governor of the region, and meanwhile he always continued his scientific career. By an original twist of fate, it was in Grenoble that he met with a gentleman by the name of Jean-François Champollion… who later deciphered Egyptian hieroglyphics. The cold temperatures in Grenoble made a sharp contrast with Fourier’s Egyptian experience, and finally ended up taking a toll on his health. Coincidence or timely matter, Fourier became interested in topics such as the evolution of temperature inside matter, and heat flow theory. In 1822, he published his work as « The Analytical Theory of Heat ». Not only did Fourier solve many mysteries about heat flow but also did he invent, in the course of his work, an invaluable mathematical tool for scientists. This is what we call today « Fourier series » (and « Fourier transform »). Fourier discovered that he could model a mathematical signal by an infinite sum of trigonometric functions. This is a profound way to decompose and solve mathematical problems. As the car manufacturer and industrialist Henry Ford said many years later (with no relation whatsoever to Fourier), « Nothing is particularly hard if you divide it into small tasks ». Transforming something complicated into something simple is something we definitely love at Stellar. So, Fourier figured out that he could transform a big complex signal into an infinite sum of small, basic, well known signals. How smart that was! Using Fourier’s technique, many problems in maths and physics can be reduced to determining the value of coefficients that multiply basic trigonometric functions. This is a major contribution to science, with countless applications in every field, from heat flow in the 19th century to the MP3 or JPG compression algorithms that make your music and pictures fit into the memory of your iPhone in the 21st century.

### « Fourier Series » in a nutshell

Not every student in science today is aware that Fourier travelled to Egypt with Napoleon. But almost everyone of them knows about of Fourier series. We can safely bet that the current reader doesn’t need any introduction either. So, what’s the principle in a nutshell? A periodic signal can be decomposed in the sum of a mean (a constant value, or harmonic of order zero), plus a sine and a cosine at the period of the signal (harmonic of order one), plus a sine and a cosine at half the period (harmonic of order two), etc. etc. until infinity. The goal of the game is to determine what coefficient needs to be put in front of each harmonic, in order to properly reconstruct the signal. It is as simple as that.

**A look inside Fourier’s mind**

### Put your new glasses on: From 2D to 3D

Sines and cosines used in the original Fourier series are well designed when accounting for 2-dimension signals. If you can plot a signal as y in function of x on your board (or tablet), then Fourier series will do the trick. That’s fine. However, could we just think out of the box for a minute (out of the plane, rather), and extend that concept to three-dimensional signals? Last time we spoke, we introduced something called the « geoid ». In our post « Is the Earth flat? », we considered the equipotential of Earth’s gravity field, which is a 3-dimensional surface, roughly a sphere, more accurately an ellipsoid, and more realistically a « potatoid » (literal transcription of the slightly colloquial, and definitely geeky French « patatoïde »). As you saw in the previous blog post illustration, the geoid has bumps and hollows. Peaks and valleys. Well, with some sort of trigonometric functions, we could imagine that it would be possible to make a similar mathematical decomposition. And render bumps and hollows with sines and cosines at proper wavelengths, this time along latitude and longitude. Trying to mimic the Fourier series process, we could invent a set of (infinite) basic trigonometric functions, this time depending on radius, latitude and longitude instead of abscissa and ordinate, and project any spherical-looking shape on this set of functions. Well, easy! Just think about it and it’s done! Look at the set of spherical harmonic functions smiling at you:

**Spherical harmonics**

We’ll deep diver into how « easy » that is in the next paragraph, but let’s skip the maths for one or two more minutes. With this set of functions, you now have the same property than with Fourier harmonics: you can decompose any object that looks « kind-of-spherical » into an infinite sum of basic functions, as long as you multiply each basic function by the right coefficient.

### A closer look

Let’s give it a closer look now. In Fourier series, you had an « order » for each harmonic. The order would define the period (or wavelength) along the x axis. In spherical harmonics, you need not one, but two numbers, in order to take into account the two directions of waves: North-South waves in the direction of Earth’s meridians (latitude), and East-West waves in the direction of Earth’s equator (longitude). This is why you now need a « degree » and an « order » to classify each spherical harmonic function. Let’s have a look at the mathematical convention. The degree « n » is the total number of waves. The order « m » is the number of waves in longitude. The number of waves in latitude is thus « n – m ». You guess that with this definition, m is always smaller than n.

Let’s continue our quick analysis. When m is equal to zero, you have no wave in longitude. You only have waves in latitude (n waves, since n=n-m since m equals zero). We call them zonal harmonics. Theses functions with dependency in latitude only look like horizontal rings on top of another.

**Zonal coefficient (n=9, m=0)**

If m is equal to n, then n-m equals zero, and there’s no room left for waves in latitude. There are only waves in longitude (n or m, since n-m=0). We call them sectorial harmonics. These functions with dependency in longitude only look like vertical « orange quarters ».

**Sectorial coefficient (n=9, m=9)**

If m is strictly greater than zero and strictly smaller than n, then you have a mix of waves in both direction (North-South and East-West). We call them tesseral harmonics. So here we are. We have our set of functions, with our three main types: zonal, sectorial and tesseral. We have an unlimited number of possibilities for the degree n, and for each degree n, we have n+1 possibilities for the order m (from 0 to n). And then we have an unlimited number of combinations of all those harmonics. All we need to do now, in order to decompose a spherical shape into spherical harmonics, is to find the right coefficient that goes in front of each fonction.

**Tesseral coefficient (n=9, m=6)**

### Back to the geoid

So let’s go back to our beloved « geoid ». Our application for gravity field is very simple. We want to describe the geoid as an infinite sum of harmonic functions. The goal of the game is to determine the right coefficient in front of each spherical harmonic function. It works like magic.

**The geoid**

So, let’s go ahead and make the decomposition. Let’s take into account the first effect that we mentioned in our « Is the Earth flat? » piece: the fact that the Earth is not flat but spherical. That would be given by the first harmonic function, a.k.a. « the mean », or the sphere (n = 0 and m = 0, no wavelengths along any direction). Then, let’s take into account the second effect that we mentioned in our post, the fact that the Earth is actually not spherical, but rather flattened at the poles. There must be a coefficient for that, yes? Well, if you take degree 2 and order 0, for example, what do you get? A « zonal » coefficient, with two wavelengths in latitude (along the whole circle): one hollow at the North pole, one bump at the equator, one hollow at the South pole, and then agin one bump at the equator. Perfect, this is exactly what we wanted. We call it « J2 » in colloquial space mechanics vocabulary. Then, what about the flattening of the equator (along the longitude direction)? Well, then the (sectorial) harmonic function of degree 2 and order 2 is the one that perfectly fits the bill. You get the point. It can go on and on. For example, if you want to account for finer details and smaller wavelengths (such as the Alps mountains that were dear to Fourier), you need higher degrees and orders. How high? For example, a spherical harmonic function of degree 200 has a wavelength of 40 000 km / 200 (circumference of the Earth divided by the number of waves), i.e. 200 km (100 km large for the bump and 100 km for the hollow). Degree 200 is about the best we can do today with space geodesy missions. Of course we can do much better with in-situ measurements campaigns, but we don’t get a full global coverage of the Earth. So by now, we’re certain you get the idea behind spherical harmonics. Let’s continue our exposé with a little practice and conclude with a little maths.

### Practice, practice, practice

There’s a famous quote among professional jazz musicians that says: « One day without practice, and you will notice. Two days without practice and critics will notice. Three days without practice and everyone will notice ». Needless to say that this wisdom applies to every single field of arts, crafts and science. It’s as true for jazz musicians who fly every summer from New Orleans (Louisiana), to perform in the small village of Marciac (Gers), as it is for geodesists who calculate satellite orbits all year long at the Space Center of Toulouse (Haute-Garonne). So, let’s put the practice quote into practice. Given that the Alps are roughly 1200 km wide (from East to West), and 300 km large (from North to South), what is the degree and order of the spherical harmonic required to account for them? Everyone who sends us a correct answer is eligible for a free coffee in our office! As a side note, we shall add two comments to that question. First: the coefficient in front of the spherical harmonic function can be positive, which allows us to account for either a bump or a hollow. Second: you might notice that we need an additional parameter which we didn’t mention until now (but will in the next paragraph), in order to phase the bump at the right place.

### A little bit of maths

Maths. We love maths. One reason is because it allows us to say a lot of things with very few words. We could basically replace almost all of our previous speech by the single following line:

This is the formula of the gravity potential in function of latitude phi, longitude lambda and radius r. This formula may look impressive at first sight, and somehow hard to digest, but it’s actually very simple. It’s an infinite sum of spherical harmonics. n is the degree (from 0 to infinity), m is the order (from 0 to n). Cnm and Snm are constants (the coefficients that we care about). Let’s have a look at what is written inside the square brackets. The dependency in longitude is a basic sine and cosine : that makes m waves in longitude around the equator. Notice that you need both a sine AND a cosine in order to phase the bump correctly. The dependency in latitude is a little more tricky. A simple sine and cosine would not accomplish all the characteristics we want to build a set of orthonormal basis functions. Instead, the dependency in latitude is a Polynomial of the sinus of the latitude. Finding the right polynomial was the work of Adrien-Marie Legendre, and they are named after him. Legendre Polynomials are calculated using recursive formulas:

With:

Just replace x by sin(phi) and you’re good to go. The dependency in longitude multiples the dependency in latitude. You just built a basis of orthonormal functions on which the decomposition is unique. Therefore, the only thing you now care about is the value of the set of coefficients Cnm and Snm. Find the right set of coefficients, and you have your description of the geoid.

### Conclusion

This is it for our brief introduction to spherical harmonics. We hope you enjoyed it. There’s a lot more to dig into for curious minds and for people who will be involved with us in space geodesy and gravity missions. The main takeaway is that spherical harmonics are a smart and convenient way to describe a spherical shape like the geoid: simply by a set of coefficients. And it was all inspired by the work of Joseph Fourier, who first had the idea of such a decomposition with basic sines and cosines for 2D signals.

Well, who would have thought that, suffering from the cold in the Alps, after coming back from an expedition to Egypt with Napoleon, would yield such fertile results, that would be used two hundred years later by geodesists all around the world??

Any comments? Questions? We love to hear from you.