Previous Up Next

17.1.4  Trigonometric interpolation

The triginterp command computes a trigonometric polynomial which interpolates given data.

L may be a list of experimental measurements of some quantity taken at regular intervals, with the first observation at time t=a and the last observation at time t=b. The resulting trigonometric polynomial has period T=n/n−1(ba), where n=size(L) is the number of observations.

As an example, assume that the following data is obtained by measuring the temperature every three hours during one day:

Hour of the day036912151821
Temperature (C)1110172432262319

Suppose that an estimate of the temperature at 13:45 is required. To obtain a trigonometric interpolation of the data:

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

−21 
2
−42

cos


1
12
π  x


+
1
8
 

−11 
2
−12

sin


1
12
π  x


+
3
4
 cos


1
6
 π  x


         
 
 
7
4
 sin


1
6
 π  x


+
1
8
 

21 
2
−42

cos


1
4
π  x


+
1
8
 

−11 
2
+12

sin


1
4
π  x


+
cos


1
3
 π  x


2
         

To plot the interpolant, enter:

labels=["time","temperature"]; legend=["hours","°C"]; plot(tp,x=0..21)

The interpolant is smooth, without oscillations, and appears realistic in the given context. Now a temperature at 13:45 can be approximated by the value of tp for x=13.75:

tp | x=13.75
     
29.4863181684           

Previous Up Next