Alglib/Python spline functions

Continuing from the previous post, the new xl_Spline-Matrix.zip spreadsheet includes functions for 1D and 2D linear and cubic splines.

xl_Spline2-1The basic 1D spline allows  for output of linear splines, or 5 different types of cubic spline, as listed above.

Output may be spline values at listed points, spline parameters for each spline segment, or spline integration or slope.

xl_Spline2-2
Additional data allows input of end slopes or curvatures for cubic splines, slope data for hermite splines, or end type and tension for Catmull-Rom splines:
xl_Spline2-3

The screenshots below show input and results for all six spline types, passing through 5 points:
xl_Spline2-4

xl_Spline2-5

Output of spline segment data, integration, and slope and curvature values is shown below:
xl_Spline2-6

Input and output for the 2D spline function is shown below.
xl_Spline2-7

The screenshots below show 2D splines fitted to tabular data for air density under varying pressure and temperature:
xl_Spline2-8

xl_Spline2-9

The xl_Spline1DFit function finds the least squares fit of a cubic spline with a specified number of segments, with optional weighting and/or constraints:
xl_Spline2-10

Alternative spline fits:
xl_Spline2-11

xl_Spline2-12

The xl_SplineInt and xl_SplineDiff functions provide integration and differentiation data for any of the spline types. They are equivalent to output options 3 or 4 with the xl_Spline1d function:
xl_Spline2-13

xl_Spline2-14

This entry was posted in AlgLib, Excel, Link to Python, Maths, Newton, Numerical integration, UDFs, VBA and tagged , , , , , , , , , , , . Bookmark the permalink.

1 Response to Alglib/Python spline functions

  1. Great article. Nicely pointed out. Thanks for sharing.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.