Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Create an interpolation augmented with first derivatives of circles through consecutive point triples
ResourceFunction["ArcInterpolation"][{{x1,f1},{x2,f2},…}] constructs an interpolation of the function values fi corresponding to values xi. |
Create an arc interpolation for some points:
In[1]:= |
Out[1]= |
Compare the fit by ArcInterpolation (orange) to a simple data set with the fit by Interpolation:
In[2]:= |
Out[5]= |
First derivatives are smoother, because a first derivative has been given to Interpolation:
In[6]:= |
Out[6]= |
The strategy for ArcInterpolation was developed to deal with inverted treasury yield curves, which cannot be well fit with Interpolation. Define data:
In[7]:= |
Out[7]= |
Create interpolations of various orders with Interpolation and ArcInterpolation:
In[8]:= |
Out[8]= |
In[9]:= |
Out[9]= |
The standard third order Interpolation has an erratic shape compared to ArcInterpolation:
In[10]:= |
Out[10]= |
Second order is a little better for Interpolation, but it still has an erratic shape at t=20:
In[11]:= |
Out[11]= |
Fourth order is useless in this case for Interpolation, but an acceptable choice for ArcInterpolation:
In[12]:= |
Out[12]= |
The option setting "Endpoints"→True changes the shape of the yield curve, extending a circular shape from the point at t=20:
In[13]:= |
Out[14]= |
ArcInterpolation makes no assumptions about monotonicity. This is an example from the resource function MonotonicInterpolation to compare fits to data. ArcInterpolation preserves the monotonicity of the data, but moves the bends in the functions to the node points:
In[15]:= |
Out[16]= |
Here is a more complicated example from the resource function CubicMonotonicInterpolation:
In[17]:= |
Out[18]= |
Here the ArcInterpolation function does not find monotonicity in the first two data points, but if it uses the end point slope extrapolated from the second data point circle then it avoids an extreme oscillation:
In[19]:= |
Out[20]= |
The recent yield curve is not monotonic, but the fit to CubicMonotonicInterpolation is similar if the "Endpoints" are included:
In[21]:= |
Out[22]= |
CubicMontonicInterpolation also supports Method→"Stineman", which gives close to the same result by using a circular derivative:
In[23]:= |
Out[24]= |
In[25]:= |
Out[25]= |
In[26]:= |
Circles through three points sequentially are shown with the points and fit to the curve:
In[27]:= |
Out[29]= |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License