Could the Earth survive a red giant Sun? So my question is that, is not a lie that we are flying away from the sun slowly, that is increasing by time because the sun loss mass, so when the scientist usually talk that we will get swallow by Sun when it get red giant, do they count on this? I mean, we can get far enough to survive or they just calculate with the actual orbit?
The answer is yes, there are many authors who do take mass loss from stars into account when trying to work out the fate of their planetary systems. Examples include Schroder &amp; Smith 2008; Adams et al. (2013); Adams &amp; Bloch (2013).

It is thought that (e.g. Kalirai et al. 2008) that the Sun will lose half its mass by the time it ends up as a white dwarf. Almost all of this mass loss occurs in the final hundred million years or so (in just over 7.5 billion years time) whilst the Sun is on the red giant branch and asymptotic giant branch. The mass loss that occurs before then is small in comparison - about $10^{-13}$ of a solar mass every year (see Noerdlinger 2008), so losing less than 1% of its mass prior to the RGB.

Consideration of conservation of angular momentum alone leads to the idea that $M(t)R$ is constant, where $M(t)$ is the mass of the Sun as a function of time and $R$ is the semi-major axis of a planetary orbit. Thus prior to the RGB phase, the Earth's orbit expands by maybe 1.4 cm per year, or by a total of $7\times 10^{-4}$ au prior to the RGB.

However, during and after the RGB we see that the Earth ends up with an orbital radius of $\sim 1.5$ au (or in solar units, about 290 $R_{\odot}$) after the RGB and maybe 430 $R_{\odot}$ after the AGB. So, whilst the Sun is in the RGB/AGB phase and losing mass, the Earth moves outwards from about 215 to 430$ R_{\odot}$. Meanwhile, as it ascends the RGB, the Sun will likely increase in size to about $200 R_{\odot}$. Therefore it is a close-run thing as to whether the Earth will be engulfed within the outer envelope of the evolved Sun.
Major uncertainties include just exactly how big the Sun will get, how much mass it will lose on the RGB and then on the AGB, and it turns out that the time-profile of the mass loss (which will happen in pulses, rather than continuously) may also play a role.

The plot below (from Schroder &amp; Smith 2008) may help to make some sense of this. It shows the (log) of the radius of the Sun versus time in the RGB and AGB phases as it loses mass. Also shown with a dashed line is the orbital radius of the Earth. Fractions written on the plot show what fraction of the Sun's present mass remains.



However, even if the Earth escapes immediate engulfment, the Sun would be several thousand times more luminous than it is today, so the temperatures at the surface of the Earth could reach $&gt;1000$ Celsius even if it stays an astronomical unit away from the Sun's surface.

A further issue is the effects of tidal dissipation. The Earth will be dragged back by tidal bulges induced in the Sun's extended envelope. The rate at which angular momentum is lost is however exquisitely sensitive to the exact radius of the Sun and the radius of the Earth's orbit, to the extent that their orders of magnitude uncertainty in whether the Earth will be dragged into the Sun's envelope even before it reaches the tip of the RGB (this is what Schroder &amp; Smith 2008 claim) or whether the loss rates will be too low to have much effect. It all depends on how much mass loss there is (Schroder &amp; Smith use a slightly lower estimate than above) and therefore what radius the Earth reaches and what the final radius of the Sun becomes.

At the moment I would say there is sufficient uncertainty that the fate of the Earth is undecided, but it will unarguably be uninhabitable.