2D piecewise linear Interpolation

 

Directly to the input form

 
  • This program demonstrates the interpolation of a real function of two variables by a continuous piecewise linear function over a triangulation of the (x,y)-data.
  • Piecewise linear continuous interpolation has a goodness of approximation similar to the onedimensional case: the approximation error is second order in the grid size (with the error constant depending on the second order partial derivatives of the function) and its gradient, although piecewise constant only, approximates the true gradient to first order in the grid size. But here the geometry of the triangularization plays an additional role. The error is bounded by O(h/sin(φ)), with φ the smallest interior angle of an triangle and h the longest edge (individually, for each triangle).
  • There are three forms of input: you either define a rectangular grid via the number of points and the grid size for the x- and y-direction, which then is transformed internally into a triangularization, or define a scattered (x,y) set, choose a predefined or self defined function, generate the z-data, interpolate these and get the interpolation and its error returned,
    or you specify a scattered set of (x,y,z) -data and get the interpolating function as a plot only.
  • a triangulation is defined internally, and the interpolating function and its gradient is obtained piecewise from independent systems of linear equations in three unknowns, over each triangle. The gradient of this piecewise linear function, being well defined in the interior of each triangle, can serve as an approximation of the gradient of the original function. In the case of artificially generated data this can be compared to the true gradient. In the case of a self defined function you don't need to specify the gradient. This is obtained here by a highly precise finite difference formula which has a much smaller discretization error than the linear interpolation can provide.
  • If you only specify (x,y,z)-data then of course no error estimation is available.
  • you might evaluate the interpolant in the case of your own data at a given set of (x,y) data. But you should be aware of the fact that the result depends on the triangulation chosen on which you have no influence. Sometimes the result may be surprising. For example if you enter the data (1,2,*),(2,0,*),(2,4,*),(3,0,*),(3,4,*) then you get three triangles: {(1,2),(2,0),(3,0)};{(1,2),(3,0),(3,4)};{(1,2),(2,4),(3,4)}. Since finding a corresponding triangle must be unique, such a point must not lie on an edge. Otherwise you get the result ''outside mesh''. Disturbing a coordinate quite a little bit might help.


Input

 
  • You first define the form of your input via a radio button: either a function based experiment, either on a rectangular grid , defined by four values n1,hx and n2,hy (number of grid points and their distance in x- and y-direction) (for generation of artificial data) or on a scattered (x,y) data set or mere input of a scattered data set of (x,y,z)-data. In the latter case you might require the interpolation results for a set of given (x,y)-data.
  • In the case of artificial data generation you might choose between 3 predefined functions or define a function yourself. This is then used to generate the z-data.
  • in both cases a (projected) 3D plot is generated. Hence you need
  • generation of a view point. This is done here by defining two rotation angles: one for the x-axis and one for the z-axis. How this works is described on the input form.
 

Output

 
  • In case of discrete 3D data of your own you get a plot of the interpolating function and the data. If required, you get a table of interpolation results. If a point does not lie inside any triangle, then you get the result ''outside mesh'' for it.
  • otherwise you get three plots: the interpolating function, the interpolation error and the error of the gradient of the interpolating function. The latter is of course discontinuous and defined in the interior of each triangle only.
  • These computations are done here in double precision. Nevertheless, if you define a smooth function and use a fine grid, then the roundoff error may dominate the interpolation error.
 

Questions ?!

  • How depends the approximation/interpolation error on the grid size? Can you verify this numerically?
  • If you use a rectangular grid with a large difference in the grid size, how does this affect the triangularization and the approximation of the gradient?
 

To the input form

 
Back to the top!

18.02.2015