5.25.27  Trigonometric interpolation : triginterp

triginterp(y,x=a..b) or triginterp(y,a,b,x) returns the trigonometric polynomial that interpolates data given in the list y . It is assumed that the list y contains ordinate components of the points with equidistant abscissa components between a and b such that the first element from y corresponds to a and the last element to b .

For example, y may be a list of experimental measurements of some quantity taken in regular intervals, with the first observation in the moment t=a and the last observation in the moment t=b . The resulting trigonometric polynomial has the period

T=
 n (b−a) n−1

where n is the number of observations ( n =size(y)). For example, assume that the following data is obtained by measuring the temperature every three hours:

 hour of the day 0 3 6 9 12 15 18 21 temperature (deg C) 11 10 17 24 32 26 23 19

Furthermore, assume that an estimate of the temperature at 13:45 is required. To obtain a trigonometric interpolation of the data, input :

tp:=triginterp([11,10,17,24,32,26,23,19],x=0..21)

Output :

81/4+(-21*sqrt(2)-42)/8*cos(pi/12*x)+
(-11*sqrt(2)-12)/8*sin(pi/12*x)+3/4*cos(pi/6*x)
-7/4*sin(pi/6*x)+(21*sqrt(2)-42)/8*cos(pi/4*x)
+(-11*sqrt(2)+12)/8*sin(pi/4*x)+1/2*cos(pi/3*x)

Now a temperature at 13:45 hrs can be approximated with the value of tp for x=13.75 . Input :

tp | x=13.75

Output :

29.4863181684

If one of the input parameters is inexact, the result will be inexact too. For example, input :

Digits:=3;
triginterp([11,10,17,24,32,26,23,19],x=0..21.0)

Output :

0.5*cos(1.05*x)-1.54*cos(0.785*x)+0.75*cos(0.524*x)
-8.96*cos(0.262*x)-0.445*sin(0.785*x)-1.75*sin(0.524*x)
-3.44*sin(0.262*x)+20.2