Unsolicited Advice VIII: Make your integrals dimensionless

By Julianne Dalcanton | December 17, 2008 1:53 pm

Having recently slogged through grading an enormous pile of graduate-level problem sets, I am compelled to share one of the most useful tricks I learned in graduate school.

Make your integrals dimensionless.

This probably seems silly to the theoretical physicists in the audience, who have a habit of changing variables and units to the point where everything is dimensionless and equals one. However, in astrophysics, you frequently are integrating over real physical quantities (numbers of photons, masses of stars, luminosities of galaxies, etc) that still have units attached. While students typically do an admirable job of setting up the necessary integrals, they frequently go off the rails when actually evaluating the integrals, as they valiantly try to propagate all those extra factors.

Here’s an example of what I mean. Suppose you want to calculate some sort of rate constant for photoionization, that when multiplied by the density of atoms, will give you the rate of photo-ionizations per volume. These sorts of rates are always density times velocity times cross section:

$latex displaystyle int_0^infty left({rm photon: density}right) , left({rm velocity}right) , left({rm cross: section} right)$

For a Planck spectrum of photons and a typical energy-dependent cross section above some threshold

$latex displaystyle int_{nu_0}^infty left(frac{u_nu}{hnu}right) , cdot ,c , cdot , sigma_0,left(frac{nu}{nu_0}right)^{-3} , {rm d}nu $

which becomes

$latex displaystyle int_{nu_0}^infty frac{8pi,hnu^3}{c^3} , frac{1}{e^{hnu/kT}-1} , cdot , c , cdot , sigma_0,left(frac{nu}{nu_0}right)^{-3} , frac{{rm d}nu}{hnu}$

This integral looks like a rough customer. You can pull some factors out front, but you’re still left with that unpleasant business in the exponential. You’re also using an integrating variable that has units, making it a bit tougher to check the dimensions of your answer to make sure it’s sensible.

Instead, if you force the variable you’re integrating over to be dimensionless:

$latex displaystyle x=frac{hnu}{kT} $

the integral reduces to something that you can start to wrap your brain around:

$latex displaystyle frac{8pi}{c^2} , frac{(x_0,kT)^3}{h^3} , sigma_0 int_{x_0}^infty , frac{1}{e^x-1} , frac{{rm d}x}{x} $

Now you have the business end of the integral out front, where you can check the units and the scaling of the answer to see if it makes sense. The integral is also something that is far simpler to evaluate (although in this case, it’s actually not a trivial integration, but at least you can recognize that early and plan on how to deal with it). If you’re in a situation where you have to integrate by parts, the dimensionless integral will save you a world of pain. Even if you make a mistake in evaluating the integral, you’re usually only off by a simple multiplicative factor like pi, or 2. All these things are good.

CATEGORIZED UNDER: Advice, Mathematics, Science
MORE ABOUT: integrals
ADVERTISEMENT
  • Vishal

    I would hope that your grad students could do simple “u-substitutions” correctly, otherwise they have no business getting a PhD!

  • http://togroklife.com greg

    I’m rather pleased that my first thought when I saw that was to define x = h(nu)/kT considering I’m just now 3 years past finishing up my physics degree and haven’t done any complex integrations like that since my very last quantum final.

  • Julianne

    Vishal — They get it right 95% of the time. But the remaining 5% of the time something goes terribly terribly wrong and they don’t catch it before the problem set is due. Your comment indicates that this is something that has perhaps never happened to you, in which case, congratulations.

  • Brett

    I have long been surprised that the technique of introducing nondimensional variables is not explicitly taught in classes that deal in macroscopic physics. Although one certainly encounters the strategy in specific examples, I know that I was never told (in an undergraduate physics class) to nondimensionalize all integrals (and partial differential equations as well).

    On the other hand, it’s second nature for many engineers and other folks dealing with fluid physics. In the process of nondimensionalizing a problem, one typically encounters one or more pure numbers that can be assembled from the basic quantities in the problem. The best known of course is the Reynolds number, which measures the relative importances of inertial effects and viscous forces. However, I’ve seen lists of dozens of such numbers that can arise just in fluid physics. The use of these “dimensionless groups,” as they are called, is ubiquitous, but it is something that students of modern physics are simply not taught.

  • Egaeus

    That sound you just heard was the explosion of the brains of all the laypeople who used to read your blog before the unfortunate calculus accident.

  • http://particlephd.wordpress.com/ Sparticles

    It may also be worth mentioning that even when using Mathematica to evaluate integrals it pays to write things in a dimensionless way since this can avoid many of the “conditional” answers that one gets by just plugging in an integral naively. That is to say that Mathematica doesn’t have to guess if certain values are constrained to be real or complex, etc.

    The point, as Brett mentions, is that doing this explicitly separates the mathematics (technical details of an integral) from the physics (the dimensionful stuff). [Ok, that’s a bit of a generalization, but one can usually glean the relevant physics without having to explicitly do integrals.]

  • JC

    @Egaeus, this may come as a big surprise to you, but physicists really aren’t the only “people” who do calculus

  • Julianne

    Egaeus — Bwah!

    Brett & Sparticles — I think why it doesn’t come up explicitly in astrophysics is that the training is typically so broad that there is never a strong incentive to establish a formal system. If you’re doing variants on fluid mechanics for a year or two, it pays to recognize the Reynolds number. But in astro, you maybe do fluid mechanics for a quarter, and then “gravitational fluids” in another quarter, and gas physics in another quarter, and galaxies in another, etc. The regimes are different, the importance of viscosity comes and goes, etc. There’s also the tension between theory and observation in the field. There is an enormous body of Stuff you have to learn in astro, where Stuff =”facts about the universe” rather than techniques for solving equations. So, sometimes the Stuff can crowd out the mechanics of theory.

  • http://countiblis.blogspot.com Count Iblis

    Putting h = c = k = 1 can also make life easier.

  • Egaeus

    @JC, I notice that you put the word people in quotes when referring to physicists. Are you trying to tell us something about them? Are they really aliens who live on nothing but coffee and conundrums?

  • Rich

    I have to agree with Vishal. Integration by substitution is a concept that should be understood far before students begin their graduate program, taught early on in calculus courses. By the second year of my undergrad, that technique became very useful in many of my electrical engineering courses.

  • Julianne

    Rich — Students know the technique, and can execute it just fine. They just haven’t gotten into the habit of doing so (though this doesn’t sound like a problem in engineering).

    Count Iblis — it’s helpful when doing the math, but awful when you want to know answers for the Real Universe. When I work with particle physicists, and I say “We should compare this to rotation curves. What is your prediction in km/s vs kiloparsecs”, it typically takes them a day to figure out.

  • JC

    @Egaeus, what! you aliens drink coffee too? :=)

  • hack

    I tell my students to always convert integrals to units of slugs per hour. I guess your students aren’t as capable as mine.

  • http://www.matthias-rampke.de/ Matthias

    I guess I’ll try to pick up that habit.

    On the other hand, for me checking the units works just fine – a dx has a length, a d(nu) has a T^-1, albeit a rather small one.

  • Imam Yahya, Commander of the Faithful, etc

    Julianne said: “Count Iblis — it’s helpful when doing the math, but awful when you want to know answers for the Real Universe. When I work with particle physicists, and I say “We should compare this to rotation curves. What is your prediction in km/s vs kiloparsecs”, it typically takes them a day to figure out.”

    You are so, so right. This disease of putting everything equal to 1, which saves no time and is due to sheer laziness, is a real pain in the butt. And apart from anything else, it’s just so *ugly* to write “exp(t)” where t is time. It has to be exp(t/T) for some time scale T.

  • http://countiblis.blogspot.com Count Iblis

    Julianne,

    Yes, it can take a little time converting from natural units back to SI or cgs units but it is not difficult. I always use well known formulas like Length = h/(mass c),
    energy = mass c^2, energy = k temperature, energy = h frequency to convert back.

    In your case, you would need to convert T^3 sigma to a rate in SI units. It is clear that in natural units this is dimensionally correct, because temperature = energy = mass and sigma has the dimensions of length squared, which is mass^(-2), so the quantity has the dimensions of mass, which is inverse length which is inverse time.

    To convert back, you can simply choose to convert each individual factor to, say, a power of energy. So, we multiply T^3 by k^3 so that it becomes energy^3. It follows from the Compton length formula that if we multiply the sigma by c^2/h^2 it becomes mass^(-2). To make this energy^(-2) we need to divide by c^4. Therefore

    (kT)^3 sigma 1/(c^2 h^2)

    is an energy. To convert to inverse time we use
    Energy = h frequency and thus divide by h:

    (kT)^3 sigma 1/(c^2 h^3)

  • TimG

    So what would be a good approach to integrate 1/[x(exp(x) – 1)] ?

  • Julianne

    Tim G — photoionization thresholds are fairly high energy compared to typical interstellar temperatures, so you can assume exp(x) is much greater than one. After that, you can do a Taylor Series expansion and keep term(s) of interest.

  • http://countiblis.blogspot.com Count Iblis

    Imam, this has its advantages and disadvantages. Thing is that h(bar), c, k etc. are ultimately conversion factors, an artifact of using incompatible units like kg, meters, seconds for mass, length and time. If you insist on inserting values for variables in formulas that are not expressed in compatible units, then the formula must do the conversion for you!

  • TimG

    Thanks, Julianne.

  • ScentOfViolets

    The heck with the u-substitution (yes, I teach calculus), a lot of grief is saved by doing the _algebra_ correctly. Your photoionization isn’t a good example for this, but too many people just throw terms up there and start whacking away at them. Also, this looks like a transcedental equation (shouldn’t be hard to prove) but for x_0>1, it converges pretty quickly, so just Taylorize it.

  • http://www.americafree.tv Marshall Eubanks

    I like your integral simplification, but I have to say that I distrust calculations by a theoretical physicist. Any paper that has a paragraph starting something like

    “Let c = G = 1 and normalize the basis functions Y(n,m) so that…”

    is likely to ignore factors of 2, PI or 4 PI^2, mix up normalizations, and thus produce equations that will look right but absolutely cannot be trusted if you are going to compare them to observables. I always feel it is best to rederive everything to make sure all of the terms are correct.

  • ScentOfViolets

    Uh, accidentally posted before finishing my scribbling, I found. A simple substitution of u=lnx gives a denominator of e^e^x-1. Yep, that’s transcendental.

  • Anne

    This is also a very good habit to get into if you’re going to attack a problem numerically: most “canned” numerical integration codes, for example, will fail horribly when handed a problem in which the typical x or y values are 10^-26. So it generally pays to handle all the numerical factors yourself and, as you say, put all the math in one place. Failing that, at the least it pays to make all quantities of order unity: if you’re doing orbital mechanics, use solar masses, AUs, and years (which has the benefit of making G 1 as well), for example. But often collecting all the numbers outside you realize that the problem doesn’t have as many variables as you thought it did…

  • http://www.irrationaltheorist.blogspot.com quantum_flux

    How about making the integrals….on the TI-89 instead?

  • Ben

    There’s always some person (often a faculty member) who says that astro students who can’t do integrals with one hand should be cast into the dungeons of Mordor or sent to engineering grad school or something like that.

    These same people rarely demand that a student should know which end of an Allen wrench is which, or know the answer themselves for that matter.

  • Charon

    Anne: G=1? You… are setting 4*pi^2=1 as well? I certainly take your point about those units being easier in Solar orbital calculations, but 39.blah != 1.

    quantum_flux: See Anne’s comment just above about very small (or very large) factors killing code. Trust me, even Mathematica, working symbolically, can barf on things like this (not exactly like the example Julianne gave, but integrals with no massaging). The TI-89 isn’t going to do any better than Mathematica.

  • Charon

    and Ben: Yes, well, they are astro grad students, not bike mechanics. (Of course, many people in Julianne’s department do know bike maintenance, but that’s not really the point of being there. Except during the Ride in the Rain competition.)

    There really are cranky faculty members, and others, who ask silly things of people sometimes. My brother, taking the California professional engineering exam, had to use standard English units instead of the SI he’d learned in, because the old guys administering it had to use English units when _they_ took it, so…

    Good advice on doing integrals is not the same.

  • http://www.savory.de/blog.htm Stu Savory

    FWIW,
    46 years ago, 1st term at university, B.Sc(Hons) Physics, we were explicitly taught dimensional analysis and to make our integrals dimensionless.

    Nothing new under the sun, Horatio :-)

  • http://countiblis.blogspot.com Count Iblis

    Even some physicists don’t understand units.

    But that’s no surprise given the way sometextbooks explain physics

  • TimG

    Count Iblis, of the objections to textbook explanations the one I don’t really get is this one:

    “Refraction of light is claimed to have no explanation in terms of particles, quoting Newton’s failure. Of course it does: As we know from quantum mechanics, Newton’s mistake was to confuse phase and group velocities.”

    The refraction of light really doesn’t have an explanation in terms of classical particles, does it? To say Newton mixed up phase and group velocity makes no sense, since classical particles have neither. That is, they just have one velocity.

  • TimG

    By the way, thanks for the link to Michael Duff’s article. The part that makes my head spin is where he basically says this (paraphrasing):

    Duff: Whether the speed of light is constant depends on your units. Obviously if you choose light-years as your unit of length and years as your unit of time, then the speed of light has to have a constant value of 1.

    Magueijo: Then what the hell was Einstein going on about?

    This has me a bit flummoxed. Of course Einstein was saying the speed of light was Lorentz invariant, not that it was constant over all time. But still, as Duff’s example shows, if you define the speed of light as your unit of speed, this invariance is trivial. On the other hand, if you define your unit of speed as something that depends on your reference frame (e.g., the speed of the Earth), then of course the speed of light changes from one frame to the other (since the speed of the Earth changes.)

    I’m thinking maybe the correct interpretation of Einstein’s postulate is that the speed of light in units of any non-reference-frame-dependent speed is Lorentz invariant. That is, if we take our unit of speed to be something like “The speed of the Earth in the rest frame of the Sun at a particular time t”, then the speed of light in that unit must be Lorentz invariant.

    Is that right? It seems a bit convoluted . . . .

  • http://countiblis.blogspot.com Count Iblis

    TimG, I agree. I think the point made by Warren Siegel here is that textbooks should simply explain what light is according to modern physics and not present the entire history of discoveries and failures first.

  • Pingback: End of the Semester; Obama’s picks, etc. « blueollie()

  • http://lablemminglounge.blogspot.com/ Lab Lemming

    Charon says:
    “Yes, well, they are astro grad students, not bike mechanics. ”

    So when the dome won’t open, you fix it how? Integrating by spare parts?

    Since starting college 17 years ago, I have learned and forgotten calculus four times.

    I have learned and forgotten soldering three times.

    Which is more important depends entirely on the scientific problem you are trying to solve.

  • http://lablemminglounge.blogspot.com/ Lab Lemming

    Brett, etc:
    For what it is worth, in geoscience the Rayleigh number is way more common than the Reynolds number.

    But just because students learn to love dimensionless variables doesn’t necessarily mean that they will take the initiative to dedimensionalize their own calculations.

  • Pingback: End-Of-Semester Bullets « The First Excited State()

  • Pingback: More Cowbell and other topics « blueollie()

  • http://mingus.as.arizona.edu/~bjw/ Ben

    Charon says (in response to my snide remark about people who demand facility with integrals but don’t know one end of an Allen wrench from another):

    “Yes, well, they are astro grad students, not bike mechanics.”

    This attitude is why astro and physics departments have an overabundance of aspiring string theory students, but good astronomical instrument builders are in short supply and high demand.

    Yes, of course, an astro grad student should know how to do integrals. And ideally, scientists (Verily, even unto the heights of Theory Division) ought to know something about the tools and instruments that produce the results.

    Lots of people do not know everything. This is why we are educators, we teach people who don’t know things; teaching people who already know everything is superfluous. Julianne’s post was in that teaching vein. Comments, like the first one, about how students should know all this integral stuff already are missing the point.

NEW ON DISCOVER
OPEN
CITIZEN SCIENCE
ADVERTISEMENT

Discover's Newsletter

Sign up to get the latest science news delivered weekly right to your inbox!

Cosmic Variance

Random samplings from a universe of ideas.
ADVERTISEMENT

See More

ADVERTISEMENT
Collapse bottom bar
+