HP Forums
Polynomial interpolation - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: HP Prime Software Library (/forum-15.html)
+--- Thread: Polynomial interpolation (/thread-7025.html)



Polynomial interpolation - JMB - 10-12-2016 08:12 PM

This is a one-line program, to find an interpolated value using a polynomial interpolation function to a set of data points.

PHP Code:
EXPORT Polynomial_Interpolation(data,x)
// data:[[x1,y1], x:value → interpolated value y
//       [x2,y2]
//       .......
//       [xn,yn]]
BEGIN
  POLYEVAL
(polynomial_regression(data,rowDim(data)-1),x);
END

Example 1: Find the interpolated value y at x=1.5, given the data points (0,3), (1,5) and (2,9)
Executing: Polynomial_Interpolation([[0,3],[1,5],[2,9]],1.5), we get: 6.75 (parabolic interpolation through 3 points)

Example 2: Find the interpolated value y at x=1.5, given the data points (1,5) and (2,9)
Executing: Polynomial_Interpolation([[1,5],[2,9]],1.5), we get: 7 (linear interpolation through 2 points)