3D Spline Interpolation
Andreas Schramm
Reinhold-Wuerth-University, Kuenzelsau, Germany
andreas.schramm@hs-heilbronn.de
Description:
This worksheet gives an example of how to use the Maple spline function to create a 3 dimensional spline surface and a function R^2->R, based on discrete values given with respect to their axes in a matrix with the first row (without the first element) containing the x-values and the first column (without the first element) containing the y-values.
The computet function and surface is continuous and differentiable. The relevant difference between least square method and spline interpolation is that no knowledge on the mathematical function describing the system behavior of the source which delivered the measured or computed values is needed. The example below results from a computation of a finite element method calculation. The next step is to get interpolated values for the purpose of minimizing calculation time of the finite element method calculation.
Maple Version: 11.02
Loading of toolboxes and defining matrix
The above described test matrix is defined here.
The x values of the contained data is stored in the first row, without the first element. Note that in this case the x-values are in descending order.
The y values of the contained data is stored in the first column, without the first element. Note that in this case the y-values are in descending order.
Data processing
For better accessibility of the data (for following plotting purposes) the data has to be processed in lists:
First we have to extract the x-values and create a list which contains m times (m = number of columns of the matrix) the x-values.
We have to do nearly the same for the y-values: creating a list which contains m times (m = number of rows of the matrix) the y-values. Note that instead of combining the interval of the y-values m times, here the y-values themselfes have to be listed after each other.
The values are also processed into a list:
This operation determines the plotting intervals:
After the data processing we can get to the core of the matter:
Spline Interpolation
For better accessibility we need to do some data processing:
We extract the x-values eliminating the non-information containing zero of the first element in the first row to get the raw data of the x-values:
The first step is to build a set of curves calculated by spline interpolation with respect to variable x with parameter y:
Display of the intermittent results
For better understanding we can plot the set of curves like following:
The second step is to interpolate the set of curves in the second dimension, which is y:
Display of the resulting spline surface
The blue circles point out the discrete data given in the above defined matrix.
Conclusion
Spline interpolation serves its purpose if you want to interpolate between data points, without knowledge of the real function. The method will give you good results in the intervals for x and y. But be aware of extrapolating out of the boundaries of x and y. Because of the method of spline interpolation the absolute return values of the interpolation function will increase to infinity. In most cases it will fail to represent real behavior.
Legal Notice: The copyright for this application is owned by the author(s). Neither Maplesoft nor the author are responsible for any errors contained within and are not liable for any damages resulting from the use of this material. This application is intended for non-commercial, non-profit use only. Contact the author for permission if you wish to use this application in for-profit activities.