# Barnes-Hut method for gravitational dynamics

I have an assignment where i got this definition - "The dots velocities following the Maxwell distribution with typical velocity of $$v=<v>^{\frac{1}{2}}$$ and that mean that each of the velocity vector components vave normal distribution with mean zero and $$\sigma = \frac{v}{\sqrt{3}}$$ Someone can explain to me the meaning of that? how the mean of all the components can be zero if for example V=85 kmh? The dots are stand for stars in galaxy, my assignment is to do Barnes-Hut Galaxy simulation.

Your question may need editing to be more clear.

Your first equation is dimensionally incorrect (velocity on the left, square root of velocity on the right). Perhaps the intention is to define a root-mean-square speed $$v_{\text{rms}}=\langle v^2\rangle^{1/2}$$ where $v=|\mathbf{v}|$ and $\mathbf{v}=(v_x,v_y,v_z)$. But you need to check.

A normal probability distribution (for each of $v_x$, $v_y$ and $v_z$) can quite reasonably have zero mean velocity $\langle v_x\rangle=0$ and similarly for $v_y$ and $v_z$ (symmetric with respect to $v_x\rightarrow -v_x$ etc). It will have nonzero standard deviation $\sigma$. In that case $\sigma^2=\langle v_x^2\rangle =\langle v_y^2\rangle= \langle v_z^2\rangle$ since all directions are equivalent.

Since $v^2=v_x^2+v_y^2+v_z^2$ it would follow that $$v_{\text{rms}}^2=\langle v_x^2\rangle +\langle v_y^2\rangle+ \langle v_z^2\rangle =3\sigma^2$$ This would be your second equation.

The distribution is a product of independent Gaussian distributions for each Cartesian component. In your program, you just need to sample each component independently from a normal distribution with zero mean and standard deviation $\sigma$.

If you look up "Maxwell-Boltzmann" distribution online you will find more details. But you will probably also see that the distribution is usually applied to atoms and molecules, with the particle mass $m$, temperature $T$, and Boltzmann's constant $k_{\text{B}}$ determining the value of $\sigma$. Those parameters might be a bit distracting in the context of setting up an astrophysical simulation, so it makes more sense to specify $\sigma$ in terms of a root-mean-square speed. I assume that is what is going on here.

But I'm just guessing. If this answer does not seem to explain things, please check the details of your assignment and clarify your question, so people can understand your problem better.