The simple answer is no, gravity does not extend out forever. Although there is a theory that states that it does.
Newton’s Law of Universal Gravitation
Newton’s law states that the force of gravity on one mass due to another mass will depend mainly on their separation. This separation is represented as r where the dependence is represented as 1/r2.
Newton’s law also states that the further you get away from the sun, your r increases, and the gravitational effect of the large astronomical body will weaken but never full dissipate. This is all, of course, according to Newton’s Law of Universal Gravitation. But it is also… wrong.
So, what is the correct answer?
Since Newton’s law is not the correct rule of gravity, we look at the most recent and correct theory which is Einstein’s General Theory of Relativity.
But to make it work in this case, we have to include the cosmological constant. General Relativity explains and describes that gravity is not necessarily direct as a classical force. But instead, that the effect called gravity is actually how objects will move and affect spacetime, which is itself curved when a mass acts upon it.
Isn’t gravity like straight lines?
No, gravitational force does not shoot out from astronomical objects in the form of straight lines that affect other bodies in space. The sun, therefore, does not shoot beams of gravitational force that cause the planets and moons to orbit it. It is actually the case that a mass will warp space and time, the fabric of spacetime.
Then, when an object travels through this space time, it will become affected by gravity in the areas that the spacetime has been warped thanks to the mass of a larger object.
General Relativity in this instance does more than just explain gravitational attraction, it also explains and describes the way that spacetime behaves as a whole fabric being affected by mass.
The behvaior of spacetime is directly affected by the mass that is present in it. As well as the energy present and the way that an object is moving.
So, what is the gravity that we feel?
The gravity on earth, and even up to the size of small groups of galaxies, shows enough localized mass within the area to make spacetime act in a way that resembles ‘normal’ gravity.
This means that scales from ants to waterfalls to even solar systems and galaxy groups will experience the same type of gravity that works in the normal way that we are accustomed to when it comes to gravity. This also means that the older dated version of our understanding of gravity, Newton’s Law of Gravity is actually being reproduced exactly in these situations.
This is not to say that Newton’s Law is correct though, since there are still measurable differences between Newton’s Law and Einstein’s Theory of General Relativity that show that Newton’s Law is still wrong.
But the gravity on this scale shows how Newton could have thought he was correct with this theory. Since the measurable differences are still relatively small. This all means that in the grand scheme of gravity, the force will cause spacetime to act in the old-fashioned way we are used to learning about.
What about gravity on larger scales?
When we reach past the scale of groups of galaxies, we reach outer space where there are relatively isolated stars, dust, planets and moons. Since these are all so spaced out compared to the astronomical objects in a solar system or galaxy, spacetime is bound to act in a different way to the spacetime in a galaxy.
This means that gravity will also appear to act differently.
Spacetime, if you imagine it as a grid, will mostly look flat and undisturbed on this scale of space. This is because space will appear mainly empty and deserted, except for some lonely astronomical bodies.
If we follow General Relativity and there are two galaxies with nothing in between them except spacetime, the galaxies will no longer be drawn together, but will actually move further apart. These galaxies are not repelling each other, it is simply that flat spacetime is expanding with the universe.
Spacetime expansion? What does this have to do with gravity?
Well, since flat and undisturbed spacetime is expanding thanks to the universe expanding, despite galaxies being next to each other, this makes things about gravity clear. It is clear that when it comes to flat spacetime, gravity does not extend out for all eternity.
If this was the case, these two neighboring galaxies would attract each other eventually. But the theory of General Relativity with the cosmological constant included shows that this is not the case, since spacetime expansion is possible. This expansion is also accelerating in time, this means that galaxies are moving further apart at a faster rate too.
This is what scientists will call cosmic expansion when spacetime expands that is relatively flat, or not affected by mass for a large area. This means that spacetime is not acting like traditional gravity as we know it here on earth.
The influence of gravity only has the capability to extend to the group that it is already in, i.e. a galaxy or galaxy group. Beyond these scales, spacetime acts more like a flat, empty vast landscape where gravity does not act in the same way. The gravitational attraction will completely dissipate outside a galaxy group.
If you were to float near the sun, you would eventually fall towards the sun; if you were to float in another galaxy, you would be moving away from our sun thanks to the spacetime between the galaxies and the cosmic expansion. You would move away at an accelerating rate and even move away from our entire galaxy.
This is because spacetime does not act like normal gravity when emptiness and flatness of spacetime is involved. This means that gravity’s influence does not extend out in an unlimited way.