  We present the evolution in the number density and stellar mass functions of
photometrically selected post-starburst galaxies in the UKIDSS Deep Survey
(UDS), with redshifts of 0.5<z<2 and stellar masses logM>10. We find that this
transitionary species of galaxy is rare at all redshifts, contributing ~5% of
the total population at z~2, to <1% by z~0.5. By comparing the mass functions
of quiescent galaxies to post-starburst galaxies at three cosmic epochs, we
show that rapid quenching of star formation can account for 100% of quiescent
galaxy formation, if the post-starburst spectral features are visible for
~250Myr. The flattening of the low mass end of the quiescent galaxy stellar
mass function seen at z~1 can be entirely explained by the addition of rapidly
quenched galaxies. Only if a significant fraction of post-starburst galaxies
have features that are visible for longer than 250Myr, or they acquire new gas
and return to the star-forming sequence, can there be significant growth of the
red sequence from a slower quenching route. The shape of the mass function of
these transitory post-starburst galaxies resembles that of quiescent galaxies
at z~2, with a preferred stellar mass of logM~10.6, but evolves steadily to
resemble that of star-forming galaxies at z<1. This leads us to propose a dual
origin for post-starburst galaxies: (1) at z>2 they are exclusively massive
galaxies that have formed the bulk of their stars during a rapid assembly
period, followed by complete quenching of further star formation, (2) at z<1
they are caused by the rapid quenching of gas-rich star-forming galaxies,
independent of stellar mass, possibly due to environment and/or gas-rich major
mergers.
