I find it difficult to understand the math methods. analysis through reference books. Did I understand correctly in the most general sense what interpolation and extrapolation are:
interpolator = (array [i] + array [i + 1]) / 2;
then we put it between array [i] and array [i + 1];
extrapolator = (array [i-2] + array [i-1] / 2);
and we put it in place of array [i].
I sketched the code myself, as best I could .. As the most primitive way to approximate the values of points, I chose the arithmetic mean between them ..
Answer 1, authority 100%
Interpolation is finding an intermediate value between two known ones, according to some algorithm. Your example is generally correct:
// For example, the arithmetic mean:
interpolator = (array [i] + array [i + 1]) / 2;
// Place between array [i] and array [i + 1]
Extrapolation , this is finding the next value from the known previous ones, according to some algorithm. The most common example would be like this:
// For example, a linear continuation over the last 2 points:
extrapolator = (array [i-1] + (array [i-1] - array [i-2]));
// Place array [i] in place
Algorithms can be very diverse, from repetition of values, to curve fitting, etc. In general, the algorithms may be similar, but extrapolation is usually more algorithmically complex.