Calculation of time autocorrelation and spectral functions using locally expanded potentials