Numerical integration using Newton formulae:
Trapezium rule for an interval from x=xi to xi+1:
Simpson rule for an interval from x=xi to xi+1:
These rules are accurate if the interval from xi to xi+1 is sufficiently small. To integrate over an interval that is not small, divide it into small ones, then integrate over each small interval and add the results.