spline( points )

The cubic spline interpolation in SageMath of the list of data points. The resulting function can be used to return values at arbitrary points in the domain of definition. Derivatives and definite integrals are available using custom methods:

f.derivative( x-value [ , order=1|2 ] )
f.definite_integral( begin, end )

Examples:

f = spline( [ (x,sin(x)) for x in srange(0,2*pi,.1) ] )
show( plot( f, x, 0, 2*pi, figsize=[4.5,2], color=(0,.5,1) ) )
f = spline( [ (x,sin(x)) for x in srange(0,2*pi,.1) ] )
show( plot( lambda x: f.derivative(x),
               x, 0, 2*pi, figsize=[4.5,2], color=(0,.5,1) ) )
f = spline( [ (x,sin(x)) for x in srange(0,2*pi,.1) ] )
show( plot( lambda x: f.definite_integral(0,x) - 1,
               x, 0, 2*pi, figsize=[4.5,2], color=(0,.5,1) ) )

Related functions:   piecewise

Function category: Basic functions sagemath-docs