# The path integral: calculating the future from an unknown past

I strongly suspected that I was a nerd during my early teenage years, but I wasn’t really sure of it until I took Calculus. Calculus was by far my favorite class in high school. I loved it because questions that seemed like they should be impossible to answer were suddenly made solvable. And not only were they solvable, but I could figure them out myself. It was an amazing sense of power.

To show you how big a deal this was to my adolescent self, let me give you an example of a question that the pre-calculus me would have thought was impossible while the post-calculus me could solve. And, just to be weird, I’ll phrase the question in the form of a conversation with myself.

- me #1: “I’ve been driving for the past hour. How much gas have I burned?”
- me #2: “I don’t know. My speed has been changing.”

Maybe this seems like a boring problem, but what a shock it was to me that such questions could be answered. In order to calculate how much gas you burned, you need to know how fast you were going (a graph like the one on the right would do the trick). But, during the last hour, you weren’t moving at one speed; you were moving at various times with a *whole bunch of different speeds*. It seems like the question should be unanswerable.

Enter Calculus, which tells you how to deal with things that are changing, even if they are changing continuously. Now you can solve the unsolvable problem. Amazing.

I’m telling you this story because a similar thing happened to me as a graduate student. A question that seemed like it should be absolutely impossible to address turned out to be solvable. Let me illustrate what kind of question it was, and how impossible it seemed, by returning to the dialogue above, this time as the post-Calculus version of myself:

- me #1: “I’ve been driving for the past hour. How much gas have I burned?”
- me #2: “Okay, I can figure that out, even though your speed has been changing. Just tell me your speed as a function of time during the last hour.”
- me #1: “I have no idea.”

Now *that* is a question that seems unanswerable. In order to calculate the amount of gas burned, you need to know your speed during the last hour — the “history” of your last hour of driving. But what if you don’t know that history? It seems like you would be up the proverbial creek without a proverbial paddle.

Enter a new kind of Calculus, one that allows you to make calculations that assess the present or predict the future, even when you don’t know the history leading up to it. In physics this math is known as the “path integral” approach, and more generally it’s called functional integration. It was astonishing to me in the way that Calculus had been during high school.

Now, I don’t have the qualifications to teach path integrals to a general audience. But I can give an example that will perhaps illustrate what the path integral approach is all about, and hint at its power in solving “impossible” problems.

**A fun problem for you, and a matter of life and death for an ant**

A (female) soldier ant is returning home from a raid on an enemy colony about 1 meter away from her own anthill. This ant, like the majority of members of many ant species, is completely blind, so finding her way home has been something of an ordeal. An even bigger danger is awaiting her this very moment, however, at the entranceway to her own home. Our soldier ant, during the course of her surprisingly violent battling, has been drenched in the pheremones of her enemy victims. If these pheremones have not worn off by now, then the sentries guarding the entranceway (who are also blind) will mistake her for an enemy. And ants are not known for their patience with enemies.

The question of “will our soldier be mistakenly killed by her own kind” depends at this moment very critically on how long it took her to walk home. The longer her path was, the better the chance that the smell of her enemies has dissipated, and the better are her odds of surviving her encounter with the sentries. If she walked at a constant speed, then we can assume the enemy pheremones dissipate exponentially (as is the case with evaporation/dissipation of chemicals on a surface). Just to make it concrete, I’ll say that her chance of being killed follows the following law:

,

where *L* is the total length of her trip home, from enemy anthill to her own. This formula implies that if our ant took a very circuitous route home — say, 20 meters long — then she has only about a 13% chance of being killed by the sentries. But if she took the most direct route — *L* = 1 meter — then there’s about a 90% chance of her being dismembered on the spot.

If we knew what path she took, we could use Calculus to figure out her path length *L* and predict what’s going to happen. But we, the observers, are only watching this moment, as the soldier returns home; we have no idea what path she took. Can we still say anything about what’s going to happen to her?

The answer, surprisingly, is yes. Usually, people use Calculus for summing (integrating) over all possible values of some quantity. The Calculus of path integrals is similar: it sums (integrates) over all possible *paths* (or histories) that connect one moment and another. And it allows us to predict the future of this ant. In evaluating whether our ant will live or die, we need to integrate over all possible paths that she could have walked along. Something like this:

If we want to know her chance of living or dying, we must average over each of these separate paths, plus an infinite number of others.

I’m only going to say here that it’s possible. Usually, there’s no simple generic solution to a path integral. In most cases you either need a computer or a lot of patience to come up with a result. And you need some way of weighting the different paths, i.e. deciding how likely the different paths are. Here I am just going to use a very simple assumption: that the ant doesn’t stray more than 4 meters from the straight line connecting her origin and destination, and that she doesn’t change her direction more often than every 8 centimeters or so. These are completely arbitrary assumptions, but they allow for a finite result. I won’t go into much detail here, but feel free to ask questions about the particulars of the calculation and I’ll respond.

Here’s the surprisingly definite result: our ant’s average path length was 9.9 meters, and as a result she has a 62% chance of surviving. Hooray for her. And hooray for us, because what what we just did is amazing to me: we made a definite prediction for the future despite a complete ignorance about the past.

**Electrons are like blind ants**

I talked about ants in my example because I happen to think they are fascinating. But I could have talked about electrons. In fact, the kind of approach I’m talking about here is a fundamental part of modern quantum mechanics. Physicists frequently ask questions about fundamental particles that are similar to my little interior monologue at the beginning of this post:

- physicist #1: “I need to know what properties an electron will have when it gets to point B, given that it started at point A”
- physicist #2: “Okay, what path does it take to get there?”
- physicist #1: “I have no idea”

Somehow physics moves on, in the face of these impossible problems. And I guess that’s why it’s so much fun.

1 – I wish I had a teacher like you when I was in school – you make everything seem so clear and simple, and very interesting.

2 – I discovered this site yesterday and I’m in love. I’ll be the first to buy your book, when you write it.

You are literally too kind. Take everything I “teach” here with a grain of salt; it represents the way I have come to think about things, but there is certainly no guarantee that it’s right. But I’m happy to hear that you are interested.

And I can’t imagine how I would ever write a book. All my good ideas are written up here for free! 🙂

“Here’s the surprisingly definite result: our ant’s average path length was 9.9 meters, and as a result she has a 62% chance of surviving.”

I’m no expert at probability, but I have trouble with saying “she has a 62% chance of surviving”. This is perhaps our best guess at her probability, but it’s not her true odds. She has some length L that she definitely walked. If that L is 1m then her actual chance of survival is 10%, and our guess is 62%.

You’re right. The most correct way to say it would have been “she has a 62% chance of surviving, given what we know.” Every time you learn new information in these kind of problems, your estimate of probability will always change.

In a sense, talking about probability only makes sense when there is some uncertainty involved. The more you know, the less you need to talk about probability at all.

I should probably make an important point here. For the ant problem, we can say that the ant followed some definite path, but we don’t know what it was so we have to make an estimate using every possible path.

For an electron (or any object you choose to describe with quantum mechanics), everything we have observed is consistent with the interpretation that the electron has somehow followed every possible path simultaneously. (See this post for how I think about that ). That’s why this path integral business is so crucial for quantum mechanics.

Another great post, Mr. G&L. My favorite part about the whole ant story, which you did not mention, is that the ant can do all that cool math in her head as well as any human physicist blogger can. This remarkable capacity for “ded reckoning” in ants has had cognitive scientists pretty stumped.

I’m not sure what you’re referring to. Please elaborate; I love learning about ants.

Well, I’m no expert, but I know that cognitive scientists have shown that certain species of ants must use some sort of calculation to find their way home because they can do so even in the absence of all other cues, like landmarks and sun. If you pick up an ant that is at a location A away from its nest, N, and move it to another location B, it will take a route that is exactly the A to N vector, but starting at point B. (See “Path integration in desert ants, Cataglyphis fortis” by Müller and Wehner, PNAS July 1, 1988 vol. 85 no. 14 5287-5290.) Researchers are still trying to figure out exactly what is going on in the ant brains, though. Perhaps your physics department should consider employing a small army of desert ants to solve its more difficult path integration problems.

“# me #2: “Okay, I can figure that out, even though your speed has been changing. Just tell me your speed as a function of time during the last hour.”

# me #1: “I have no idea.”

And that’s why calculus has no utility in the real world. You never know the function. The only useful thing I took away from calculus (other than letting me pass the test to get into the math major at my college) was a couple patterns of thought like taking things to the limit to see what vanishes, looking for upper and lower bounds on an answer, and shifting your frame of reference like with polar coordinates. But differentiation and integration have no usefulness because you never know the function. The path thing is OK but seems to be more like a brute force computer solution than math.

I should have been complimenting you over picking the awesomely relevant-feeling example of gas in the tank in the first place, but I decided to have a little anti-calculus rant instead.

I had a brief internship at an engineering company as an undergraduate, and I was told that statistics was infinitely more important than Calculus. It made me sad.

Although I think the question of “how useful is Calculus” is very dependent on where you work. I personally use it every day, and I like to think that what I do is useful. As an example, the “price of anarchy”, “Ewing Theory”, “feeling of time”, “solitary waves”, “most important idea in science”, and “Gompertz Law” posts all required me to use Calculus.

Don’t feel sad that, “statistics was infinitely more important than Calculus.” Doing a path integral *is* doing statistics — in fact, it’s marginalization over all possible paths. Rather, I’d take issue with statistics-is-more-important mainly because Calculus (which tells us how to take an average) is one of the most fundamental tools of statistics.

Actually, there is another cool problem hidden in the ant problem. I’m interested in your characteristic length, 10 meters. How could one determine this length? Let’s call it X. Well, it could be determined from evaporation rates, as you suggest. But instead you could look at the fates of some number (the more the better) of ants returning from the enemy nest. Given your probability of survival of one ant (which is missing a normalization factor, by the way. Partition function! Partition function!), the probability of n ants dying and N-n ants surviving is

P(n, given N, L, X) = (Pdeath)^n (1-Pdeath)^(N-n)

which is a function of L, which we don’t know, and X, which I’m trying to figure out. What you did was to guess a reasonable distribution for L, P(L), to do your path integral. To figure out X, you’d do the path integral on P(n, given N, L, X) instead of on Pdeath. The result would be (closely related to) the probability distribution of X, from which we could estimate X itself (by its mean or by the peak of the distribution or whathaveyou).

So I’d agree that statistics is important — it helps us to figure out interesting things! But it cannot be done without integral Calculus.

Good points, all. Putting up artificial barriers between calculus and statistics is almost always a bad idea.

The formula P_{death} is already normalized. The probability that an ant will die during the interval (L, L + dL) is -dP/dL. So the function needs to satisfy \int_0^\infty (-dP/dL) = 1. Which it does.

Ah, right, yours is a probability; mine would have to be a density.

Are you kidding me?

Calculus is the single most applied field of math in the entire world. Despite the importance of other fields, a huge portion of physics and engineering in the real world work intricately with calculus. When you don’t “know the function” (even though surprisingly often we know a very good approximation), that’s when more advanced manifestations of calculus like differential equations, calculus of variations, and yes even path integrals come into play. I’m in physics, math, and applied math, and speaking ill about calculus is one of the most laughable opinions I’ve ever heard of.

Are you *kidding* me?

To expand on this: the real power of the Calculus is exactly when you don’t know (an explicit formula for) the function. That Noumenon and others don’t realize this basically shows what a poor grasp of the subject they have.

I can’t really see the calculus in the Gompertz’ law post, but I’m happy to assume there’s calculus underlying everything. I just never come upon the kind of tricky/well-defined problems that I could use calculus to solve myself.

A very nice introduction to path-integrals. Thanks for the post.

How is “path integration” any different from a monte carlo simulation of the ant’s possible path home? I must be missing something.

Hi Marc,

If the Monte Carlo simulation is well-made, then they accomplish the same thing. The difference is that a simulation takes a finite number of randomly-chosen paths and assumes that they are a fair representation of reality. A path integral actually accounts for all of the infinity paths that could have been taken, the same way a regular integral considers all the infinity points between two limits.

Of course, if the actual integral is too hard to solve exactly, people often resort to numerical approximation and Monte Carlo methods, so the line between them can get a little blurred.

Hi. Thanks for that. I was wondering if you had a suggestion for some introductory reading materials so that I can learn how to use path integrals. For some fun, I was working on the Feynman ‘lifeguard’, problem which I worked out using the standard calculus tools and now wanted to try to solving it using path integrals. Can you suggest something? While I did take a quantum mechanics course years ago I do not remember anything so preferably something that does not use examples from QM.

Thanks