Interpolations.jl icon indicating copy to clipboard operation
Interpolations.jl copied to clipboard

Free(OnGrid()) boundary conditions produce surprising results

Open cchapmanbird opened this issue 1 year ago • 4 comments

I'm interpolating a 3-dimensional regular surface with scale(interpolate(Espldata, BSpline(Cubic(<bc>))) where is either Line(OnGrid()) or Free(OnGrid()). I am confused by the below result, which is a 1D slice through the grid with the other two parameters being grid points. Why do the Free boundary conditions behave so poorly? My impression is that Free BCs are the same as not-a-knot (continuity in third derivative for second-last spline knot) but this is clearly not what is happening here.

image

cchapmanbird avatar Nov 30 '23 14:11 cchapmanbird

You've encountered https://en.wikipedia.org/wiki/Runge%27s_phenomenon

mkitti avatar Dec 01 '23 00:12 mkitti

I have never seen such a bad case of it for not-a-knot cubic splines - especially for such a simple function. The true curve appears almost linear at the boundary but the cubic polynomial is totally different...

I suppose more nodes is the only answer?

cchapmanbird avatar Dec 01 '23 00:12 cchapmanbird

Perhaps. The reality is that you probably only need more nodes near the boundaries.

true curve appears almost linear at the boundary

Have you tried Natural?

Also consider https://github.com/jipolanco/BSplineKit.jl https://github.com/JuliaApproximation/ApproxFun.jl

mkitti avatar Dec 01 '23 07:12 mkitti

Thanks for the recommendations - I did not know about BSplineKit.jl.

I thought that Line is an alias for Natural? In the docs....

"The following boundary conditions are implemented: Flat, Line (alternatively, Natural), Free, Periodic and Reflect."

cchapmanbird avatar Dec 01 '23 13:12 cchapmanbird