Previous ToC Up Next

## 3.1. Choosing a Distance

Alice: Now I understand what your code is doing, except for a few crucial lines. First there is the one-liner about choosing the distance between a new star and the center of the star cluster:

```     radius = 1.0 / sqrt( rand ** (-2.0/3.0) - 1.0)
```

Can you tell me what this expression means, and how it is derived? It must somehow be related to the density distribution , which you have already derived from the potential. How exactly do Aarseth, Henon and Wielen use the density for particle sprinkling?

Bob: They describe their technique in a few words, and I had to read those words carefully, and do some head scratching, to figure out what it meant. But as always, once you see it, it is really easy. Let me try to summarize it in my own words.

First we introduce the cumulative mass distribution which is the amount of mass contained within the star cluster inside a distance from the center. When we create a new star, and place it at radius , that star will see an amount of mass of the cluster at positions closer to the center than its own position, and therefore an amount of mass at positions further from the center.

In other words, it will see a fraction of the total mass inside its radial position. Now that fraction could be anything between 0 and 1. It will be 0 if the particle is placed exactly in the center, and it will approach 1 if the particle is placed very far away, reaching 1 when the particle is placed at infinity.

The ranking of each particle, in terms of the enclosed mass, is random and uniform in the mass fraction. In other words, will be a random value between 0 and 1, with each value equally likely.

So here is the idea: spin a random number generator in order to obtain a a random number , with , and we consider that to be the fractional mass contained within the radius of particle . So all we know is that , but what we need to know is itself. So the procedure is to invert (18) to obtain a function , and then life is simple: .

## 3.2. Following the Recipe

Alice: That sounds straightforward. Can you show me the expressions you found for and ?

Bob: I simply took their expressions. They use a system of units in which the total mass M, the gravitational constant G and the structural length scale a that we used above are all unity. The mass enclosed within a radius r then becomes: and the radius that corresponds to a mass fraction becomes: As you can see in the second line of the inner loop in my mkplummer method, this is how I determine the radial position of each particle, using Ruby's random number generator rand:

```     radius = 1.0 / sqrt( rand ** (-2.0/3.0) - 1.0)
```

Alice: Hmm. You didn't check whether they had done their math correctly?

Bob: No need to. This is a paper by Aarseth, Henon, and Wielen. Besides, it is thirty years old and has been cited zillions of times by others. I'm sure this is a result that can be trusted.

Alice: I don't like to accept things on trust, no matter what the authority may be behind it. Not that I expect them to be wrong, I agree that that would be highly improbable. Still, I would feel much better if we derive the results ourselves. Besides, if we work it out now, we can both use those notes when we have to teach it in class to the students. Better still, we just put it into the material we prepare for them on the web.

Bob: Okay, if you like. Your turn, though, I already derived the density. Do you want to use a package from symbolic integration? Differentiation is easy enough by hand, but I must admit, I'm a bit rusty in my integration.

## 3.3. Cumulative Mass

Alice: So am I, and that is a really good reason to do it with pen and paper, tempting as it is to use a symbolic package. Okay. I'll start with the density you derived: By definition, this gives us for the cumulative mass, as a function of radius: The variable appears in the integrand only in terms of the combination , so a natural change of variables is: which gives us: It is easier to bring the total mass to the other side, as an expression for the fractional cumulative mass. I don't like the high power in the integrand. I'll use integration by parts to lower the power: That looks a bit better already. How about another change of variables: This gives us: So here is what we were looking for: Indeed eq. (19), with their choice of units.

## 3.4. Physical Intuition

Bob: Well, if you are rusty in your integrations, then I don't know what to call myself. Nice job! It is always surprising to me how the result of that type of calculation can come out in such a simple form.

Alice: There probably is a good physical reason for it to be this simple. Let's think. I started with density, something that you had found by differentiation, and then I integrated the product of the density and the geometric opening angle factor of . Apart from that factor, integration and differentiation would have canceled. Pity.

Bob: Hey, wait a minute. I found the density by integrating alright, but in the following way, using Poisson's equation: Doesn't that have exactly the factor you were looking for?

Alice: It does . . . Hey, I could have started there! I could have written: Bob: Ah, I remember telling you that it might come in handy to have the derivatives of the potential at hand.

Alice: Not only that, here is the physical meaning we were looking for! You also mentioned that the gradient of the potential is the gravitational force, apart from a minus sign. So what this equation is telling us, is simply that the physical force is proportional to mass and inversely proportional to the radius squared: Newton's gravity! We could have started that way. The magnitude of the force on a particle with mass at distance from the center is of course: and also equal to: since everywhere.

Bob: You're right. If we would have started with those two lines, we could have written right away. And with the expression I wrote down yesterday, this would have given us: Alice: Quite a bit faster than my juggling of integrals! We could have used a healthy dose of physical intuition, before embarking on that lengthy computation.

## 3.5. An Intuitive Derivation

Bob: Now that we have found the radius dependence of the cumulative mass, we only have to invert that relationship, to get the dependence of cumulative mass on radius. That shouldn't be too hard. However, I'm getting tired of carrying along the factors and which we may as well consider to be the physical units used for measuring and , so that the latter are used as dimensionless parameters. Setting , we can write:     which is indeed eq. (
20) that you asked me to derive. No need to trust anybody anymore! We have derived it from first principles.

Alice: But you'd better explain your students how you can restore the correct factors of and , otherwise they will think that you were cutting corners.

Bob: Good point. It takes a while to learn to think in terms of dimensionless quantities, and to transform easily and confidently between those and the corresponding physical quantities. In this case, I can just point out that the dimensionless quantity has to be replaced by , and the dimensionless quantity has to be replaced by . We then get: Alice: That is correct, but if I were your student, I would be rather surprised. I would argue that a piece of wood with a length of 1 foot has also a length of 12 inches. So you have to multiply the unit of length with the dimensionless number 1 or 12, as the case may be, to get the physical length. So I would ask: why are you dividing by the length scale ?

Bob: Yes, students do indeed ask such questions! It just means that they have to practice more with simple examples, until it comes to them naturally.

Alice: Well, that is not really answering the question. My answer would be to introduce two different sets of symbols, to remove the confusion between the physical quantities and the dimensionless quantities.

Bob: I won't stop you!

## 3.6. A Formal Derivation

Alice: If you define you can point out that and are physical quantities, while is the dimensionless quantity connecting them. Similarly, and are physical quantities, while is the dimensionless quantity giving the variable quantity in terms of the mass unit . We can then write: This makes is possible to write your derivation without any shortcuts, in a mathematically precise way.         Bob: Yes, that is full mathematical rigor. But of course, in practice, you wouldn't go to such extravagance. This is like what you were pushing for earlier, with your request of putting hats on all kind of variables, just because their mathematical functional form changed. Since I'm a physicist, I prefer to change notation only if the physical meaning of the variables change.

Alice: I must admit, I often do use this type of switching of variables, along the lines of what I just illustrated. I can see that you're comfortable with omitting that step, and that is mostly a matter of taste, I guess. Still, you can't insist or wish that your students have the same quirks or abilities as you. So I suggest we at least add my derivation as well.

Bob: In that case I insist that we leave my derivation in too, for those younger versions of me who already got the physics, and don't want to accrete unnecessary mathematical niceties.

Alice: So be it.
 Previous ToC Up Next