This is because pcubature starts with a low order rule and samples the integrand at the three points 0, π and 2π for which sin^2 is identically 0. Similarly, when the integrand is cos^2 it returns 2π because the integrand at those points is 1. (Note that hcubature gives the correct result in both cases.)
Currently there is no way of specifying a higher order rule: can this be supported?
pcubature
gives the wrong answer when integratingsin(x)^2
in the interval[0,2π]
: it should be π, it returns instead 0 (thread in discourse)This is because
pcubature
starts with a low order rule and samples the integrand at the three points 0, π and 2π for whichsin^2
is identically 0. Similarly, when the integrand iscos^2
it returns 2π because the integrand at those points is 1. (Note thathcubature
gives the correct result in both cases.)Currently there is no way of specifying a higher order rule: can this be supported?