Modeling the chemotactic response of Escherichia coli to time-varying stimuli