Further Examples: Interpolation
Here is a table of values of the square root function at the points .
This constructs an approximate function that represents these 10 values on the domain .
The values of the function match the data at the given points.
The function sqrt1 also gives a fair approximation to the square root function at other points between and .
A plot of the difference between the two functions shows that the approximation is better at some points than at others.
Here is another set of data that gives values of the square root function as well as its derivatives at the points .
Here is the corresponding interpolating function.
The values of this function likewise match the data at the given points.
Here is the plot of the difference between the square root function and sqrt2.
This shows that in general sqrt2 gives a significantly better approximation to the square root function than sqrt1 does.
Finding Closest Integers
This defines the function closestIntegers which returns the integers in list1 that are closest to those in list2.
This creates an InterpolatingFunction object which repeats itself periodically. The data at the endpoints of the fundamental period must match: otherwise the function would not be periodic.
In more than one dimension, you can specify that some dimensions be repeated periodically and that others are not by giving the value of the option as a list. This sets up an InterpolatingFunction which will be periodic in the second dimension but not in the first.