  We formulate a theory of thermal expansion based on the self-consistent
phonon (SCP) theory, which nonperturbatively considers the anharmonic effect.
We show that the Gr\"unseisen formula holds within the SCP theory by replacing
the phonon frequency by the SCP frequency. By comparing it with the
quasiharmonic approximation (QHA), we derive explicit formulas of the
correction to the QHA result. We show that the phonon anharmonicity gives a
small correction of $O(\langle{\hat{U}_4\rangle}/\langle{\hat{U}_2\rangle})$ to
the thermal expansion coefficient $\alpha$, where $\hat{U}_2$ and $\hat{U}_4$
are the harmonic and the quartic terms of the potential energy surface. On the
other hand, we show that the phonon anharmonicity gives two correction terms to
the temperature ($T$)-dependent phonon frequency shift which are comparable to
the original QHA term. In strongly anharmonic materials such as NaCl and MgO,
these two correction terms tend to cancel out each other, which explains why
the QHA sometimes gives reasonable values for the $T$-dependent phonon
frequency shift while it fails for thermal expansion.
