Why is the Andromeda galaxy coming closer to Milky way?

If both these galaxies are on collision path because of their gravity but how could that be?

They are 2.5 million light-years apart now but I imagine they are still n collision path for a long time and the universe is 14 billion years old.

Does this mean they could be 20 million light-years away at some point yet their gravity started to attract each other?

• That's not very far on a galactic scale, though. The diameter of the Milky Way is around 105,000 light years, and that of Andromeda is about 220,000 light years. It's hard to tell the exact size, due to the dark matter. Mar 27, 2020 at 4:58

I can't see where you get 20 million light years from. They are 2.5 million light years apart now, and will collide in about 5 billion years time. This suggest perhaps that when they formed around 12.5 billion years ago, they might have been, at most, 9 million light years apart.

Both galaxies are of mass $$\sim 2\times 10^{42}$$ kg. If they were 9 million light years apart, then each would feel an acceleration of about $$2\times 10^{-14}$$ m/s$$^2$$. Even were that acceleration to stay uniform (it of course increases as $$1/r^2$$), they would cover half the distance between them in just 70 billion years. Thus merger on a timescale of about the current age of the universe is not unexpected.

A more general way of thinking about it is in terms of the typical gravitational dynamical timecscale $$\tau \sim (G\bar{\rho})^{-1/2}$$, where $$\bar{\rho}$$ is the average density of a structure. The local group of galaxies is dominated by Andromdeda and the Milky Way, and is about 10 million light years across and contains about $$5\times 10^{42}$$ kg, so $$\bar{\rho} \sim 10^{-26}$$ kg/m$$^{3}$$ and $$\tau \sim 40$$ billion years. Again, this suggests a merger after $$\sim 16$$ billion years of evolution is not unexpected.

they could be 20 million light years away at some point yet their gravity started to attract each other?

Gravity has infinite range. It gets weaker and weaker as you go further away, but there isn’t a cutoff point where it goes to zero. It’s an “inverse square” law and $$1/r^2$$ is nonzero at arbitrarily large $$r$$.

We don't actually know that Andromeda is on a collision path. It is coming closer, but in the absence of an accurate determination of proper motion, that does not imply collision. Gravity cannot (on its own) explain the observed randomness in peculiar velocities of galaxies. Galaxies were formed from gas clouds. The conclusion should be that peculiar velocities already obtained in the initial conditions of galaxies formation. This is natural since one expect high velocities to be generated is gas in the conditions of the big bang. I have considered this in some depth in The effects of turbulence generated in Big Bang nucleosynthesis

• ui.adsabs.harvard.edu/abs/2012ApJ...753....8V/abstract Mar 27, 2020 at 7:45
• In the abstract of your linked paper, you say "High levels of turbulence follow, triggering the Jeans mechanism and leading to the formation of galaxies and large-scale structure in the order of 10 Myrs. [...], general relativity predicts that there is no bound on the size of the structures produced". That sounds quite plausible, but isn't this an area of active research? You almost make it sound like you've solved the key problems of the origins of the galaxies. That'd be rather nice. :) Mar 27, 2020 at 7:49
• BTW, I've noticed that your answers often link to your offsite works. That's perfectly fine, but the official Stack Exchange policy regarding this is that you must disclose your affiliation in your answers, even if it's obvious at the linked document. Please see help/promotion & this FAQ for details. Mar 27, 2020 at 8:06
• @Rob Jeffries, the abstract of this paper confirms that a collision path is consistent with, but not shown, by the measured tangential velocity. I have also seen a report of a measurement suggesting that tangential velocity is sufficient to exclude collision, but I have no reference and cannot confirm veracity. Mar 27, 2020 at 8:39
• @PM2Ring, it really should be an area of active research, but one can only find a small number of cosmologists and astrophysicists advocating void models. The majority of reviewers are far more concerned that accepted authority should not be refuted. Mar 27, 2020 at 8:43