Given a real function $f$, how can one efficiently evaluate $\int_0^{a_i}f(x)dx$ for millions of different $a_i$?
Applying a standard quadrature method (such as Simpson's rule or Gaussian quadrature) will incur an independent cost for each $a_i$, since in general $f(x)$ will need to be evaluated at an entirely different set of points for each $a_i$.
I would prefer to pre-generate/calculate a data structure at substantial initial cost, if the integral can then be evaluated from this data structure cheaply, for different $a_i$.
One possibility I see is to evaluate the integral at a regular array of points $x_j=a_{max}j/n$ (which would allow reuse of points in Simpson's method), and then to "correct" this integral on final evaluation with a small $\int_{a_{max}j/n}^{a_i}f(x)dx$ which can be evaluated with a very low-order Gaussian quadrature because $j$ can be chosen to make this correction interval small. Although probably accurate, it seems like this method may give rise to discontinuities at the half-way points between subsequent $j$.
Another possibility may be to fit cubic splines to a regular array of points (evaluated from Simpson's method) and then rely on these to interpolate the integral.
I would rather follow an established approach if there is one.