如何在辛普森函数上正确引入并行性?
simpsonIntegrate f a b n =
parMap rseq( (s + s4 + s2) * h / 6)
where
s = f a + f b
s4 = 4 * (sum . map f $ [a + h/2, a + h/2 + h .. b - h/2])
s2 = 2 * (sum . map f $ [a + h, a + 2*h .. b - h])
h = (b - a) / n