Skip to main content
2 of 6
added 100 characters in body
george2079
  • 39.1k
  • 1
  • 44
  • 111

One idea is to integrate once to get the sample points then compute the remaining integrals as sums:

 sample = SortBy[ 
     First@Last@
        Reap[ NIntegrate[x (c = Cos[10 x + Cos[x]]), {x, 0, 5}, 
            EvaluationMonitor :> Sow[{x, c}]] ]  , #[[1]] &];

 wt = ((#[[3]] - #[[1]])/2) & /@ 
     Partition[Join[{0}, (#[[1]] & /@ sample ) , {5}] , 3 , 1 ] ;

 wt . ((Transpose[sample][[2]]) (Transpose[sample][[1]]))
 wt . ((Transpose[sample][[2]]) (Transpose[sample][[1]])^2)
 wt . ((Transpose[sample][[2]]) (Transpose[sample][[1]])^3)

{0.0133333, 0.133275, 0.861541}

Note the accuracy is not terribly good, NIntegrate gives:

{0.0125266, 0.131514, 0.855716}

Somethings a bit off in my quick&dirty trapezoid integration but i think this can be made to work.

george2079
  • 39.1k
  • 1
  • 44
  • 111