I am making a $n$-body simulation, and for reasons beyond the purposes of this question, I need to know what is the gravitational potential energy, but when i searched up in google this formula showed up:
$$-G\frac{m_1m_2}{r}.$$
what this formula says is that, the further away the two bodies are, the smaller is the gravitational potential energy, but then from where does the kinetic energy come from when the two bodies are closer together?
I mean, when the two bodies are far away, with no speed, both gravitational potential and kinetic energy are low, and when they start to approach each other (because of gravity) both gravitational potential and kinetic energy are high. Doesn't this violate conservation of energy?