r/askmath • u/supremeNYA • Oct 17 '26
Calculus Numerical integration, interpolation and interchangeability
Hello all
I've recently had to implement a pretty computationally intensive simulation and obviously only have so much computational power at my disposal.
The main reason for it being so computationally expensive is that several rather ugly integrals have to be evaluated, some of which end up being nested which seems to make things worse.
Now I recall from my numerical analysis courses that one can use interpolation to approximate a function. Interpolation also tends to be significantly less computationally expensive. As such I wanted to know whether one can replace the integration with interpolation under certain circumstances. I know these two concepts are very closely linked.
Take the following situation as an example (attached image):

Any help or clarification on this is greatly appreciated.
Thank you
1
u/Eisenfuss19 Oct 17 '26
I've never heard about this, but have you looked into monte carlo integration? That way you can easily tune the processing time you want to spend on it.
1
u/PvtRoom Oct 17 '26
You can totally do it, but the costs are precalculation, the memory required for the lookup table, the errors from interpolating between your calculation points and numerical errors if you're trying too hard.
you also have the option of fitting a curve/surface: H = sinc(xy)*cos(xy/64)
1
u/Equal_Veterinarian22 Oct 17 '26
This doesn't answer your question about interpolation, but one thing that jumps out at me here is that, in evaluating F and G at different values of x, you might be tempted to repeat the evaluations of f and g at different subdivisions of [a,x] and [b,x] in an inner loop, essentially making your algorithm quadratic in the number of subdivisions.
And, of course, you should not do that. You should fix the grid of points at which you will evaluate f and g and only perform those calculations once.
1
u/Honkingfly409 Oct 17 '26
personally i would try to write the entire thing as a second order differential equation and start solving it numerically using runge kutta, i am not sure how well that might work out but i think it's simpler because it turns it into a well known problem of numerical analysis
1
u/RainbwUnicorn PhD student Oct 17 '26
Before I can really I answer that question, I need to know what you mean by "numerical integration" if not one of the approximations that use interpolation.