Message Boards Message Boards

How to extract the functional form of interpolation function, B-Spline...?

Can anyone be kind enough to explain to me how to extract the functional form of the resultant interpolation function, B-Spline, Bezier Function, or any other curve fitting/data analysis technique? I'm interested to see what is the functional form of the the function that is representing my 2D data. Later I need to plot this function in a different software, that's why I will need to acquire the resulting Bezier Function or the interpolation function.

6 Replies

Thanks Henrik, it does help a lot.

Hi Javid,

OK, here comes annother try: The idea is to use Shannon interpolation, i.e. one obtains a (lengthy) sum of sinc functions as an analytic expression. But to avoid oscillations between data points it is necessary to extend the data in a way so that their values go smoothly towards zero on both sides of the interval. I did this using BSplineFunction. My result finally looks like this (the blue points are your original data, the continuous curve shows the Shannon interpolation):

enter image description here

Here is my code; it should be quite self-explaining:

ClearAll["Global`*"]
data  (* = <...your data ...>; *)
data = SortBy[data, First];
{xmin, leftY} = First@data;
{xmax, rightY} = Last@data;
dDelta = (xmax - xmin)/10;
leftF = BSplineFunction[{{xmin, leftY}, {xmin - dDelta, 
     leftY - dDelta (rightY - leftY)/(xmax - xmin)}, {xmin - 2 dDelta,
      0}, {xmin - 3 dDelta, 0}}];
rightF = BSplineFunction[{{xmax, rightY}, {xmax + dDelta, 
     rightY + dDelta (rightY - leftY)/(xmax - xmin)}, {xmax + 
      2 dDelta, 0}, {xmax + 3 dDelta, 0}}];
(* extended data: *)
data1 = SortBy[Join[Table[leftF[t/4], {t, 1, 4}], data, Table[rightF[t/4], {t, 1, 4}]], First];
xmin1 = data1[[1, 1]];
xmax1 = data1[[-1, 1]];
(* aequidistant resampling: *)
dDelta = (xmax1 - xmin1)/40;
ifunc = Interpolation[data1];
idata = Table[{x, ifunc[x]}, {x, xmin1, xmax1, dDelta}];
(* proper definition of sinc function *)
sinc = Sinc[Pi #] &;
(* resulting Shannon interpolation: *)    
shannonIP[x_] = Total[#2 sinc[(x - #1)/dDelta] & @@@ idata];
Plot[shannonIP[x], {x, xmin1, xmax1}, 
 Epilog -> {PointSize[Large], Red, Point[idata], PointSize[Medium], 
   Blue, Point[data]}, GridLines -> {{xmin, xmax}, None}, 
 ImageSize -> Large]

Hope this helps! Regards -- Henrik

POSTED BY: Henrik Schachner

Thank you for the replies. The data being processed are:

data={{-0.0893812, -0.0140775}, {-0.0904977, -0.0146514}, {-0.0914695, -0.0154373}, {-0.0924943, -0.0161461}, {-0.0934767,-0.0169158},{-0.0943115, -0.0178996}, {-0.0951481, -0.0188803}, {-0.0958544, -0.0200493}, {-0.0965879, -0.0211791}, {-0.0974918, -0.0220623}, {-0.0984529, -0.0228627}, {-0.0992755, -0.0238636}, {-0.100107, -0.0248522}, {-0.100968, -0.0257978}, {-0.101778, -0.0268171}, {-0.102616, -0.0277946}, {-0.103483, -0.0287318}, {-0.104312, -0.0297239}, {-0.105068, -0.0308208}, {-0.105771, -0.0319949}, {-0.106386, -0.0332957}, {-0.106925, -0.0347073}, {-0.107456, -0.0361294}, {-0.108057, -0.0374492},{-0.108753, -0.0386353}, {-0.109534, -0.0396923}, {-0.110253, -0.040859}, {-0.110614, -0.0422182}}

S M Blinder: thanks for the material, I will study them carefully.

Henrik: Thank you for the suggestion, FindFormula is a very rough approximation of the data for my purposes. Try ifun = Interpolation[data] Plot[ifun[x], {x, -0.089381226, -0.110613757}, Epilog -> Point[data]]

You'll see the level of accuracy required. Only if I could see the output function that represents the final curve you see here.

Daniel: Thanks for your reply. You are looking at the data considered. The goal is to find the functional form that accurately interpolates these data set. This is actually a part of a geometry that will be deformed in a finite element code. I'm doing this to get a proper parameterization of the geometry to be able to perform a shape optimization, just to give you an idea of my purposes here. B-splines and Bezier Functions are all that comes up in the literature. I don't really care so much about the backend stuff that produces the interpolated function, as I will only use this function to parameterize the geometry.

Thanks,

It's easier to respond to a question like this when presented with a concrete example (in Mathematica format).

POSTED BY: Daniel Lichtblau

You might try the new experimental function FindFormula (see documentation).

POSTED BY: Henrik Schachner

Programs producing Bezier functions, etc. do not generally show the functional form of the interpolated curve. They usually involve what are called Bernstein polynomials. You might be able to work out the functions after reading http://pomax.github.io/bezierinfo/

POSTED BY: S M Blinder
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract