Although the details are not really understandable as mentioned already by Christopher Landauer you could expand the cos and sin functions in terms of complex exponentials and rewrite the sum under the integral as sum (numerical coefficient)*(complex exponentials). now you get on integration something like sum (numerical coefficient)*integral (complex exponentials) dz. for the latter integrals you get explicit results easily. Then you have a something like sixteen sums to evaluate (2 complex exponentials for cos, 2 complex exponentals for sin to be multplied) will give normally 4*4 different complex exponentials to be integrated - this you should do by hand(!) - maybe with the help of some computer algebra - in order to simplify the computational burden. Of these, you only need the real part unless the coefficients are complex in your original sum... Whether this results in a speedup remains to be seen. At least the remaining work for the computer is then nothing but multiplications and additions per time step ... Just give it a try...