# 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

Contributed by:
Robert Rimmer

ResourceFunction["ArcInterpolation"][{{ constructs an interpolation of the function values |

The input must be a list of {*x*,*y*} pairs of real numbers.

The interpolations are smoother when the data is ordered by *x*_{i}.

ResourceFunction["ArcInterpolation"] uses Interpolation and returns an InterpolatingFunction object.

ResourceFunction["ArcInterpolation"] adds a first derivative for each midpoint of sequential three points, calculated using CircleThrough on the three points. It returns Automatic if there would be a division by zero error.

ResourceFunction["ArcInterpolation"] has an option "Endpoints" (default False), which, when set to True, which will calculate the slope of the first and last points from the second and penultimate circles.

It passes on relevant options such as InterpolationOrder to Interpolation (although Method→"Spline" is not supported because derivatives are being used).

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

- 1.0.0 – 06 December 2023

This work is licensed under a Creative Commons Attribution 4.0 International License