Tha wasn't a good idea. Using a vector as input was OK. Its dangerous to mix up rangevariables and vectors. Range variable are good for three kind of things only: use them to index vectors & matrices, in programs in for-loops, in 2D-plots. Thats all. Don't confuse them with vectors just because they may look alike.
Look at the attached sheet if it would help. I set up the function to take a single scalar as parameter, but I am still unsure as of the integral. You can't take the parameter of the function as variable of integration.