The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
Polynomial interpolation
10-12-2016, 08:12 PM (This post was last modified: 11-06-2016 11:47 AM by JMB.)
Post: #1
Polynomial interpolation
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)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Polynomial interpolation - JMB - 10-12-2016 08:12 PM



User(s) browsing this thread: 3 Guest(s)