Trigonometric interpolation

1.6k Views Asked by At

From http://en.wikipedia.org/wiki/Trigonometric_interpolation trigonometric interpolation can be calculated as follows:

Trigonometric interpolation

Now assume we have 6 data points (0, 0.1), (1, 0.3), (2, 0.4), (5, 0.3), (6, 0.2), (7, 0). We want to interpolate the two missing points at 3 and 4.

Data points

How can we calculate the two missing points using trigonometric interpolation?

1

There are 1 best solutions below

1
On BEST ANSWER

Here is a simple answer with the Pascal code mentioned in the comment. Please note that only the missing points are computed not the explicit polynomial:

const
  x: array[0..5] of double = (0,   1,   2,   5,   6,   7);
  y: array[0..5] of double = (0.1, 0.3, 0.4, 0.3, 0.2, 0);

function interpol(u: double): double;
var
  k,m: integer;
  p,f,s: double;
begin
  p := 0.0;
  for k:=0 to 4 do begin
    f := 1.0;
    for m:=0 to 4 do begin
      if m<>k then begin
        s :=   sin(0.25*(u   -x[m])/Pi);
        s := s/sin(0.25*(x[k]-x[m])/Pi);
        f := s*f;
      end;
    end;
    p := p+f*y[k];
  end;
  interpol := p;
end;

var
  u: double;
begin
  u := 3.0;
  writeln('u p(u) = ', u:6:2, interpol(u):10:2);
  u := 4.0;
  writeln('u p(u) = ', u:6:2, interpol(u):10:2);
end.

The output is:

u p(u) =   3.00      0.42
u p(u) =   4.00      0.38