system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: Why exactly will the sun expand?

I'm trying to learn more about astrophysics, and one thing I can't wrap around is how the sun and other stars will expand near the end of their lifetime. The reason people give is that when the hydrogen in the core depletes, a star fuses heavier elements together and therefore the inner pressure "wins" against gravity.

What I don't really understand is how fusion of heavier atoms would increase the pressure. Wouldn't that mean that fusing them together creates more energy than the fusion of hydrogen? Which isn't true if I understood fusion correctly.
gpt
You have it backwards. The higher pressure *causes* the fusion of heavier nuclei (not atoms - electrons don't stick to nuclei at the temperatures found in stars).

More precisely, the chain of events looks like this:

* Before a star is born, a hydrogen cloud slowly collapses under its own gravity. Initially, this raises pressure and temperature at the center.
* Once the pressure and temperature at the center get high enough, hydrogen fusion ignites. That fusion produces a lot of energy, which makes the core very hot. And as you probably learned in high school chemistry, heating a gas increases the pressure it exerts. (Okay, technically the material here is a plasma, but the same laws more-or-less apply.)
* Because higher pressure increases fusion rate (and thus energy output) and lower pressure decreases it, the inward pressure of gravity and outward thermal pressure reach a stable equilibrium.
* This stable equilibrium lasts throughout the star's time on the main sequence. As fusion products (mostly helium nuclei) build up in the core, the fusion gets less efficient, which means gravity wins out just a little, increasing the star's core temperature until the outward pressure rises enough to counterbalance it again. From the outside, this manifests as stars getting slightly hotter (and thus slightly larger, since the higher temperature puffs up their outer layers) as they age.
* Near the end of the star's life, so much helium has built up in the core that hydrogen fusion slows down enough that the core collapses to a very high density, much higher than in previous stages.

What happens then depends on the star's size:

If the star is quite large (about twice the size of the sun or more), this is enough to raise the pressure and temperature enough to ignite helium fusion, which raises the star's energy output and re-establishes the equilibrium that had persisted throughout its time on the main sequence. 

But for smaller stars, we need a little more physics.

Up until this point, the thermal pressure from the extremely high temperatures from the energy released by fusion has been the dominant force holding a low-mass star up. But as the pressure rises higher and higher, the nuclei in the core begin to physically run out of space.

It's a general rule of particle physics that two particles (more properly, fermions) can't be in the same place at the same time *at the same energy level*. So when the space runs out, the nuclei in the core have to jump up to higher energy levels - they can no longer stick around in their ground state. (Imagine, say, a stadium that fills up so people have to start sitting on each others' laps.) Pushing particles up to those higher energy states, and keeping them there, "consumes" some of the pressure that would normally be compressing the matter further - or, as we usually think of it, results in an extra outward pressure on top of the thermal pressure that has been involved so far. This extra outward pressure is called *degeneracy pressure*, and it quickly comes to be the *main* force stopping further collapse (outstripping the thermal pressure pushing outward).

This continues until the pressure and temperature get so high that that helium fusion ignites. But *unlike* the earlier ignitions, this ignition *doesn't* immediately establish an equilibrium, because thermal pressure is no longer doing much. If you have 1000 units of degeneracy pressure and 1 unit of thermal pressure, then even heating the core by a factor of 100 doesn't change things much - you go from 1001 units of total pressure to 1100. So once fusion ignites, there's a temporary runaway reaction that isn't stopped by a new equilibrium for a relatively long time in particle physics terms (a couple of minutes). This is called a *helium flash*, and for those couple of minutes, the star produces energy at a rate comparable to whole large galaxies.

Eventually the flash makes the core so hot that thermal pressure once again becomes the main force, reestablishing the equilibrium.

In either case:

* Now that helium fusion is lit, the outward pressure from fusion (possibly assisted by degeneracy pressure depending on the star) re-establishes the equilibrium from earlier - but the output of the now-very-compressed core is much, much higher. That causes its outer layers to puff out, since there's more outward push from the energy flowing from the core. (This actually makes the star's *surface* cooler, because it's spreading an increased energy output over a drastically increased area.) The star is now a red giant.