Numerical Python Computing Assignment-217.pdf - Chapter 7...

This preview shows page 1 - 4 out of 4 pages.

Chapter 7 Interpolation Figure 7-1. Polynomial interpolation of four data points, using power basis and the Chebyshev basis While interpolation with different polynomial bases is convenient due to the functions for the generalized Vandermonde matrices, there is an even simpler and better method available. Each polynomial class provides a class method fit that can be used to compute an interpolation polynomial. 1 The two interpolation functions that were computed manually in the previous
example could therefore instead be computed in the following manner: using the power basis and its Polynomial class, we obtain: In [46]: f1b = P.Polynomial.fit(x, y, deg) In [47]: f1b Out[47]: Polynomial([ 4.1875, 3.1875, -1.6875, -1.6875], domain=[ 1., 4.], window=[-1., 1.]) and by using the class method fit from the Chebyshev class instead, we obtain: In [48]: f2b = P.Chebyshev.fit(x, y, deg) In [49]: f2b Out[49]: Chebyshev([ 3.34375 , 1.921875, -0.84375 , - 0.421875], domain=[ 1., 4.], window=[-1., 1.])
Note that with this method, the domain attribute of the resulting instances are automatically set to the appropriate

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture