Description
Given the values of a known function y=f(x) at a sequence of ordered points x0,x1,⋯,xn, find f(x) for arbitrary x. When x0≤x≤xn, the problem is called interpolation. When x<x0 or x>xn, the problem is called extrapolation.
The easiest way to interpolate, is connecting two points of a curve with a straight line that can be built with two points (x0,f(x0)) and (x1,f(x1)) and the line equation becomes:
x1−x0f(x1)−f(x0)=x−x0f(x)−f(x0) f(x)=f(x0)+x1−x0f(x1)−f(x0)(x−x0) Then we solve for f(x) and we can get all the values from x0 to x1, but if the function is not a line, an error should be introduced and if we know the real value of f(x), the percentage error is:
ep=f(xreal)f(xreal)−f(xinterpolated)