Try rewrite the function f into a theano function, remove the numpy.vectorize, and use the integration theano.Ops from below.
f
numpy.vectorize