quadgk integration of the sin and cos functions takes several seconds when 
integrated between 0 and 2pi, versus fractional seconds when integrated 
between 0 and pi. Any ideas as to why this might be? My first thought was 
that quadgk might have different behavior when the function integrates to 
zero, but that fails to explain why sin(x)*cos(x) (which integrates to zero 
between both 0--pi and 0--2pi) runs fast for 0--pi and slow for 0--2pi. 

f(x) = sin(x)*cos(x)

function quadgktest()
  println("="^40)
  @time quadgk(sin, 0., pi)
  @time quadgk(f, 0., pi)
  @time quadgk(sin, 0., 2.*pi)
  @time quadgk(f, 0., 2.*pi)
end


   - 
   
   elapsed time: 4.5545e-5 seconds (2312 bytes allocated)
   elapsed time: 0.000117391 seconds (84752 bytes allocated)
   
   - 
   
   elapsed time: 1.488471598 seconds (454495576 bytes allocated, 47.06% gc time)
   
   - 
   
   elapsed time: 3.658246353 seconds (984390504 bytes allocated, 51.24% gc time)
   
   

Reply via email to