 # Most Accurate/Efficient Interpolation approach for 1D/2D, discrete-continuous hybrid problem

Hi all, looking for advice on the best way to get very accurate results in finite computing time, for this problem:

A discrete grid in `x`, with `f(x)` values at each point. For any initial choice of `x0`, need to interpolate `f(x)` in the neighboring area, do a bunch of calculations on `f(x)` to get new function `f2(x)` in this neighborhood, then find where the local minimum of `f2(x)` is.
(The problem has to stay as continuous as possible, since the minimum place for `f2`, at `xMin`, does NOT have to be at one of the discrete data locations, but should be found as precisely as possible.)

But, this is actually a 2D problem, in time `t` and position `x`. Because after it calculates that `xMin`, it steps to `xMin` and ahead to the next time value, and then begins the process all over again for the next timestep: it finds the next `xMin` for the new `t`, and continues stepping again and again unless it gets to the end time. (At almost all times, the stepper will be located in between the actual discrete `x` data points, not exactly on one of them.)

Also, the problem is also somewhat continuous in t, because the whole 2D function I’m starting with is really obtained as a numerical solution to a partial differential equation using the Method of Lines. So, at each `x` point, what I really have isn’t just a single data point, but is an ODE interpolation solution `x(t)`, so it is continuous in time (sort of). So, maybe there is a more holistic interpolation approach that can do the whole 2D interpolation in `(t,x)` at once, for the neighborhood around the place where the stepper is located at the moment.

This problem is complicated, so I’d appreciate any advice on either the simpler problem (for a single value of `t`) – discrete data points, interpolation, calculations with the interpolation, continuous minimum finding – or on the whole 2D problem (if possible).

Thanks!

BTW, I’ve heard of ApproxFun for approximating a whole data set, but I’m not sure if that’s the best choice here, because I’m only interpolating a few (~10-20) `f(x)` data points in the neighborhood of my `x` for the stepper, not the function at all `x` everywhere.

1 Like

Your question is underspecified: a lot depends on the properties of your function.

I am not sure I fully understand the question, but a simple tensored spectral (eg Chebyshev polynomial) approach may work with sufficiently smooth/differentiable functions. As always, I would recommend

1 Like

A physics-informed neural network or a tensor product of 1D universal approximators as Tamas mentions.

Thanks for the links & references guys, I’ll check it out.

For now, to develop some procedures, I’m just working with the plain wave equation:
`ftt = fxx`.
(That is, `d^2/dt^2 {f(t,x)} = d^2/dx^2 {f(t,x)}` .)

I guess what I was more specifically asking with my question, is whether Julia has a 2-dimensional version of a “spline”-like interpolator. Preferably where it can handle discrete data in one dimension (`x`), and 1D interpolation data (coming from ODE integrators) in the other diimension (`t`). Or, at least, a 2D interpolation that can handle discrete data in both dimensions (`t,x`).