...anyone could prove that this code spews nonsense if you give it a function that isn't defined on the interval. Try log(x) on [0;1] and enjoy the calculation. It cannot be calculated, because it's infinite...The script will give you a rubbish value.
Even better, try x/sin(x) on -pi;pi. It'll give you something, but the integral cannot be calculated.
The ONLY true way to calculate the area is to find a primitive, and use the range formulas.