q-expansion and theta functions