title: Getting spline equation from UnivariateSpline object
body: <p>I'm using UnivariateSpline to construct piecewise polynomials for some data that I have. I would then like to use these splines in other programs (either in C or FORTRAN) and so I would like to understand the equation behind the generated spline.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import numpy as np
  import scipy as sp
  from  scipy.interpolate import UnivariateSpline
  import matplotlib.pyplot as plt
  import bisect
  
  data = np.loadtxt('test_C12H26.dat')
  Tmid = 800.0
  print "Tmid", Tmid
  nmid = bisect.bisect(data[:,0],Tmid)
  fig = plt.figure()
  plt.plot(data[:,0], data[:,7],ls='',marker='o',markevery=20)
  npts = len(data[:,0])
  #print "npts", npts
  w = np.ones(npts)
  w[0] = 100
  w[nmid] = 100
  w[npts-1] = 100
  spline1 = UnivariateSpline(data[:nmid,0],data[:nmid,7],s=1,w=w[:nmid])
  coeffs = spline1.get_coeffs()
  print coeffs
  print spline1.get_knots()
  print spline1.get_residual()
  print coeffs[0] + coeffs[1] * (data[0,0] - data[0,0]) \
                  + coeffs[2] * (data[0,0] - data[0,0])**2 \
                  + coeffs[3] * (data[0,0] - data[0,0])**3, \
        data[0,7]
  print coeffs[0] + coeffs[1] * (data[nmid,0] - data[0,0]) \
                  + coeffs[2] * (data[nmid,0] - data[0,0])**2 \
                  + coeffs[3] * (data[nmid,0] - data[0,0])**3, \
        data[nmid,7]
  
  print Tmid,data[-1,0]
  spline2 = UnivariateSpline(data[nmid-1:,0],data[nmid-1:,7],s=1,w=w[nmid-1:])
  print spline2.get_coeffs()
  print spline2.get_knots()
  print spline2.get_residual()
  plt.plot(data[:,0],spline1(data[:,0]))
  plt.plot(data[:,0],spline2(data[:,0]))
  plt.savefig('test.png')
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Qfv0Y.png" alt="splines"></p>
  
  <p>And here is the resulting plot. I believe I have valid splines for each interval but it looks like my spline equation is not correct... I can't find any reference to what it is supposed to be in the scipy documentation. Anybody knows? Thanks !</p>