quad_qag slow due to compilation at each step?



I'm not sure, but I am beginning to suspect that my code may be very 
slow because quad_qag calls get-integrand which calls compile. I am 
essentially doing a find-root of a quad_qag every time I call my 
function which means that quad_qag gets called 20 times or so for each 
outer function evaluation... each time find root calls it, it's 
re-compiling the integrand.

I don't know whether in this specific case, the overhead of compile is 
worth it. Any suggestions as to how to deal with this??

Perhaps I just try replacing quad_qag with romberg... but in general how 
should maxima handle this case? Is there a way we can provide the user 
with a mechanism to hand quadpack functions a pre-compiled integrand?

Thanks for any suggestions.