Sorry, folks… usually the lack of content around here is due to sheer laziness and distractedness on my part, but the last few days I really have been extremely busy. My notes tell me I’ve worked 36 hours in the last three days, and that’s 36 hours of actual work, not reading comics while pretending to be working or whatever many people say they’re doing. It’s something I’m working on, but I’m not currently the most disciplined person on the block. Sometimes I can go for long stretches without feeling like I got anything useful done, and at other times I can go for long stretches able to think of nothing else but a particular thorny problem. While the latter situation results in a lot of work getting done, it isn’t actually discipline — if you can’t bring yourself to walk away from something even when you would ordinarily want to and nothing external is keeping you, you may not be in control. But that, while an interesting topic, is a topic for another post.
The thing that’s kept me so, um, gainfully occupied in the last few days was a pernicious software bug — or, rather, an undocumented feature. I don’t expect this to be of general interest, so I’ll just quickly advertise up front that this is like a long shaggy dog joke, except with calculus. It should give you a window into the kinds of things I worry about often enough. So:
One of the things that astronomers do a lot is measure brightnesses of things. That’s not even easy to do accurately for nearby stars, because of the Earth’s atmosphere, but at least it follows physics that is fairly accessible to folks who’ve taken a 101-level course: light from the star spreads out more or less evenly in all directions, so if you can correct for the fact that the Earth’s atmosphere absorbs some of that starlight, you can get some idea of how intense the flux (erg cm-2 s-1) of light is at the top of the Earth’s atmosphere. And after that it’s just the inverse square law, which says that the luminosity, or energy output per unit time (erg s-1), is proportional to one over the square of the distance.
Think you got that? Awesome! The straight-up inverse square law applies for anything close enough and moving slowly enough that we don’t have to use relativity (either special or general) to describe how it appears to us. It’s fine for anything in our Galaxy, in nearby galaxies like Andromeda, and even some as far out as a few tens of millions of light years. So that’s quite a far way out.
But inevitably, the Universe is a big place, and as we get into the regime of “cosmology”, or the study of the Universe’s structure, composition and history as a whole, that bigness starts to manifest in some pretty weird ways. Those familiar with Hubble’s Law will know that Edwin Hubble’s claim to fame was measuring distances to other galaxies — in part to prove that they were actually other galaxies and not just collections of stars in our own Galaxy (this wasn’t known in 1929!). One of the things Hubble found was that the more distant galaxies appear to be moving away from us, because the light we see from those object is redshifted. The absorption or emission features in a galaxy’s spectrum made by different chemical elements appear to us on Earth (in the “observer frame” of reference) at different, longer, wavelengths than they would if we were observing a sample of those elements in the lab, or in that galaxy itself (the “rest frame”). They appear longer by a factor of (1+z), where the number z which we call the redshift is proportional to its distance from us (for sufficiently nearby galaxies).
The combination (1+z) appears a lot in cosmology, and affects nearly every conceivable physical quantity we can measure when we transform that quantity from its rest-frame value to the observer-frame value it has when we actually measure it. The wavelength of light from faraway galaxies is stretched by a factor of (1+z) before it reaches us. Intervals of time also become longer by a factor of (1+z), due to relativistic time dilation. The energies of photons, quanta of light, become lower by a factor of (1+z), since the energy is inversely proportional to the wavelength (which increases) or, equivalently, directly proportional to the frequency (which could be said to decrease due to time dilation). Composite quantities like the flux from an object, energy per unit time per unit area, pick up several factors of (1+z) and you have to get them all right to get the right answer.
You can see how this might start driving you batty. But it gets worse, because different groups of researchers use different conventions for how they group all the factors of (1+z) together. Suppose you’ve measured the flux in erg cm-2 s-1 from a distant object (such as a supernova, as I have), and you want to know its luminosity in erg s-1. You divide by the square of the distance, and include some number of factors of (1+z). You could account for things by increasing the measured flux by two factors of (1+z) (higher energy, shorter time interval) and then multiply by the square of the “comoving distance” which would be measured by a tape measure if there were one long enough for you to string out behind you in a spaceship traveling from here to where the supernova went off. That seems intuitive, and it’s what Hubble originally did in his own work. On the other hand, if you’re an astronomer, you don’t increase the flux at all, but you multiply by the square of the so-called “luminosity distance” which, by convention, is just the coordinate distance times (1+z). The two approaches are mathematically equivalent, but unless you keep all the factors of (1+z) sorted out so that you can make sure you’ve applied the right number, you’re bound to get confused.
And this indeed is the very danger of using clever software programs that are meant to keep track of all of this for you. They can be a godsend and make your job a lot easier, but you have to know what conventions they’re using.
In this case I was transforming the spectrum (erg cm-2 s-1 angstrom-1, a real doozy!) of a supernova from observer frame to rest frame, in order to measure its luminosity. A spectrum needs three** factors of (1+z) to transform from observer frame to rest frame — one for the energy (erg), one for the time interval (s), and one for the wavelength bin of the spectrum (angstrom). The software library I was using, which I didn’t write, dutifully applied all three factors of (1+z), according to Hubble’s convention. One of those factors would disappear when integrating the spectrum over wavelength to get a flux, and the software assumed I would use the square of the coordinate distance to get the luminosity. Unaware of this fact, I used the luminosity distance, the square of which included another two factors of (1+z). So I ended up getting a luminosity which was a factor of (1+z)2 too large.
This was a relatively nearby supernova (z = 0.07, a mere 1 billion light years away), so I was only 15% off… but (a) it could’ve been worse, and (b) although it didn’t change my conclusions for this supernova, it could have for others, where the situation isn’t as clear and the balance between competing hypotheses is much finer. I wouldn’t have noticed it, except that I was also getting luminosities from images (which of course don’t have a wavelength bin, because the integral over wavelength has already been done by the filter on the camera), and saw that the answers I got from imaging and from integrating spectra differed by a factor of (1+z).
Moral of the story, kids, make sure you know what your software is doing. Otherwise you’ll spend three whole days making every plot you can think of, inserting print statements into every corner of your code and generally questioning your sanity. It can be a humbling and character-building experience, but it’ll harm your efficiency if you indulge in it too often.
** (Edit: The original version of this post asserted that adding three factors of 1+z is common in physics but not in astronomy. In fact mention of Hubble using it in this paper by Oke & Sandage is the only mention of it I can find in the literature; the luminosity distance approach appears to be pretty standard in the field. And I believe it would be the right thing to do if the object, whether galaxy, quasar, or supernova, were redshifted by 1+z due to a special-relativistic Doppler shift in the neighborhood of our Galaxy; but the conventions are different for general-relativistic cosmology-style redshifting at very large distances.)