Added comments for easier review
Addition of integrate function to allow x1 and x2 to be entered instead of x[1] and x[2].