From New Scientist:
[quote author=“Précis”]Solar system could go haywire before the Sun dies
Two new studies suggest a collision with Mercury or Mars could doom the Earth long before the Sun becomes a red giant in about 5 billion years. The studies suggest that the planets’ orbits may not be stable beyond another 40 million years. Predicting what will happen is extremely challenging because so many bodies are involved. Even small errors today can translate into huge uncertainties in the future. Because of this, astronomers are only able to say that the solar system will remain stable for the next 40 million years.
Now, new calculations suggest that there is a 1 to 2% chance that Mercury’s orbit will get seriously perturbed within 5 billion years, destabilising the whole inner solar system and leading to a catastrophic collision between Earth and either Mercury or Mars. According to co-author Gregory Laughlin, a collision with Mars would leave the Earth as hot as “a red giant star” for a thousand years.
In the other study, Jacques Laskar of the Paris Observatory, ran 1001 computer simulations of the solar system, with slightly different starting conditions, in a method called ensemble modelling. Again, in 1 to 2% of cases, Mercury’s orbit became very elongated due to the gravitational pull of Jupiter, increasing its interactions with Venus, Mars and Earth and possibly throwing the whole solar system into disarray.
“Once Mercury’s eccentricity gets up above about 0.6, ” Laughlin told New Scientist, “[...] then all bets are off

