Interpolation: Difference between revisions

From Met Dynamics
Jump to navigation Jump to search
imported>Scott.Munro
imported>Scott.Munro
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
== Model theory ==
== Model theory ==


[[File:Interpolation2.png|thumb|400px|Figure 1. An example of cubic spline interpolation with linear extrapolation at the extents.]]
[[File:Interpolation2.png|thumb|425px|Figure 1. An example of cubic spline interpolation with linear extrapolation at the extents. The spline shown is non-monotonic.]]


=== Linear interpolation ===
=== Linear interpolation ===
Line 22: Line 22:


Given a set of distinct data points <math>(x_1, y_1), (x_2, y_2), \dots, (x_n, y_n)</math>, where <math>x_1<x_2< \dots < x_n</math>, a cubic spline interpolator constructs a piecewise cubic polynomial <math>S(x)</math> that satisfies the following conditions:
Given a set of distinct data points <math>(x_1, y_1), (x_2, y_2), \dots, (x_n, y_n)</math>, where <math>x_1<x_2< \dots < x_n</math>, a cubic spline interpolator constructs a piecewise cubic polynomial <math>S(x)</math> that satisfies the following conditions:
# Interpolation: <math>S(x_i) = y_i</math> for <math>i=1,2,\dots,n</math>. (The spline passes through all data points.)
# Interpolation: <math>S(x_i) = y_i</math> for <math>i=1,2,\dots,n</math>. (The spline passes through all data points).
# Smoothness: <math>S(x)</math> and its first two derivatives are continuous across the entire interval <math>[x_1, x_n]</math>. (The spline has no abrupt changes in its slope or curvature.)
# Smoothness: <math>S(x)</math> and its first two derivatives are continuous across the entire interval <math>[x_1, x_n]</math>. (The spline has no abrupt changes in its slope or curvature).


Cubic splines offer enhanced accuracy and flexibility compared to linear interpolation, especially for functions with nonlinear behavior.
Cubic splines offer enhanced accuracy and flexibility compared to linear interpolation, especially for functions with nonlinear behavior.


This implementation of cubic spines also applies linear extrapolation at the extents of the data set, as illustrated in Figure 1.
The following features are also applied for this implementation of cubic splines:
* Linear extrapolation at the extents of the data set, as illustrated in Figure 1, and
* Monotonicity of the spline may be optionally enforced.


Please see the Wikipedia article on [[wikipedia:Spline interpolation|Spline interpolation]] or references such as Napier-Munn et al. (1996) for a more detailed description of cubic spline interpolation.{{Napier-Munn et al. (1996)}}
Please see the Wikipedia articles on [[wikipedia:Spline interpolation|Spline interpolation]] and [[wikipedia:Monotone cubic interpolation|Monotone cubic interpolation]], or references such as Napier-Munn et al. (1996) for a more detailed description of cubic spline interpolation.{{Napier-Munn et al. (1996)}}


== Excel ==
== Excel ==
Line 39: Line 41:
and
and


<syntaxhighlight lang="vb">=mdInterp_CubicSpline(known_xs as Range, known_ys as Range, xs as Range)</syntaxhighlight>
<syntaxhighlight lang="vb">=mdInterp_CubicSpline(known_xs as Range, known_ys as Range, xs as Range, Optional monotonic as Boolean = false)</syntaxhighlight>


{{Excel (Text, Help, No Arguments)}}
{{Excel (Text, Help, No Arguments)}}

Latest revision as of 08:57, 22 June 2024

Description

This article describes linear and cubic spline data interpolation methods.

Model theory

Figure 1. An example of cubic spline interpolation with linear extrapolation at the extents. The spline shown is non-monotonic.

Linear interpolation

Linear interpolation is a technique for approximating the value of a function between two known data points. It involves constructing a straight line that passes through the two given points and using this line to estimate the value of the function at an intermediate point.

Given two data points and , where , the linear interpolation formula to estimate the value at a point within the interval is:

Linear interpolation provides a simple and computationally efficient method for approximating function values.

Cubic spline interpolation

Cubic spline interpolation uses a piecewise cubic polynomial to approximate a function smoothly between known data points.

Given a set of distinct data points , where , a cubic spline interpolator constructs a piecewise cubic polynomial that satisfies the following conditions:

  1. Interpolation: for . (The spline passes through all data points).
  2. Smoothness: and its first two derivatives are continuous across the entire interval . (The spline has no abrupt changes in its slope or curvature).

Cubic splines offer enhanced accuracy and flexibility compared to linear interpolation, especially for functions with nonlinear behavior.

The following features are also applied for this implementation of cubic splines:

  • Linear extrapolation at the extents of the data set, as illustrated in Figure 1, and
  • Monotonicity of the spline may be optionally enforced.

Please see the Wikipedia articles on Spline interpolation and Monotone cubic interpolation, or references such as Napier-Munn et al. (1996) for a more detailed description of cubic spline interpolation.[1]

Excel

The interpolation methods may be invoked from the Excel formula bar with the following function calls:

=mdInterp_Linear(known_xs as Range, known_ys as Range, xs as Range)

and

=mdInterp_CubicSpline(known_xs as Range, known_ys as Range, xs as Range, Optional monotonic as Boolean = false)

Invoking the function with no arguments will print Help text associated with the model, including a link to this page.

The input parameters and calculation results are defined below in matrix notation, along with an example image showing the selection of the same cells and arrays in the Excel interface:

where:

  • is the number of data points
  • is the number of interpolation points
  • is an array of the known independent data values
  • is an array of the known dependent data values
  • is an array of the independent data values at which the dependant variable is to be interpolated
  • is an array of the interpolated dependant variable values
Figure 1. Example showing the selection of the known_xs (blue frame), known_ys (red frame), xs (purple frame), and Results (light blue frame) arrays in Excel.

References

  1. Napier-Munn, T.J., Morrell, S., Morrison, R.D. and Kojovic, T., 1996. Mineral comminution circuits: their operation and optimisation. Julius Kruttschnitt Mineral Research Centre, Indooroopilly, QLD.