Previous Up Next

6.27.30  Trigonometric interpolation: triginterp

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


Example.
For example, y may be a list of experimental measurements of some quantity taken in 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 (ba)
n−1

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

hour of the day036912151821
temperature (C)1110172432262319

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
+
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
         

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:

     
 
20.2−8.96 cos
0.262 x
−3.44 sin
0.262 x
+ 0.75 cos
0.524 x
         
 
1.75 sin
0.524 x
−1.54 cos
0.785 x
− 0.445 sin
0.785 x
+ 0.5 cos
1.05 x
         

Previous Up Next