The theoretical investigation of time-dependent quantum systems requires the solution of the time-dependent Schrödinger (Dirac) equation. The basis generator method presented here allows a systematic construction of dynamically adapted wavefunctions based on a decomposition of the Hilbert space into a hierarchical structure of finite subspaces. For the class of interactions obeying an inverse integer power law, e.g., Coulomb and polarization interactions, an explicit representation of the dynamically optimized basis set is given.