10.2.6 Trigonometric interpolation
The triginterp
command computes a trigonometric polynomial which interpolates given data.
-
triginterp takes four arguments:
-
L, a list of numbers.
- a, a number (the beginning of an interval).
- b, a number (the end of the interval).
- x, the name of a variable.
The last three arguments can also be given as x=a..b.
- triginterp(L,a,b,x) or
triginterp(L,x=a..b)
returns the trigonometric polynomial that interpolates data given in the list
L. It is assumed that the list L contains
ordinate components of the points with equidistant abscissa components
between a and b such that the first element of L
corresponds to a and the last element to b.
Example
The 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
where n=size(L) is the number of observations.
For a concrete 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 (∘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:
tp:=triginterp([11,10,17,24,32,26,23,19],x=0..21) |
| | | | +
| | | ⎛
⎜
⎝ | −21 | √ | | −42 | ⎞
⎟
⎠ | cos | ⎛
⎜
⎜
⎝ | |
π x | ⎞
⎟
⎟
⎠ | +
| | | ⎛
⎜
⎝ | −11 | √ | | −12 | ⎞
⎟
⎠ | sin | ⎛
⎜
⎜
⎝ | |
π x | ⎞
⎟
⎟
⎠ | +
| | cos | ⎛
⎜
⎜
⎝ | | π x | ⎞
⎟
⎟
⎠ | − |
| | | | | | | | | |
| | | sin | ⎛
⎜
⎜
⎝ | | π x | ⎞
⎟
⎟
⎠ | +
| | | ⎛
⎜
⎝ | 21 | √ | | −42 | ⎞
⎟
⎠ | cos | ⎛
⎜
⎜
⎝ | |
π x | ⎞
⎟
⎟
⎠ | +
| | | ⎛
⎜
⎝ | −11 | √ | | +12 | ⎞
⎟
⎠ | sin | ⎛
⎜
⎜
⎝ | |
π x | ⎞
⎟
⎟
⎠ | +
| |
| | | | | | | | | |
|
Now a temperature at 13:45 hrs can be approximated with the value of
tp for x=13.75.
If one of the input parameters is inexact, the result will also be inexact.
For example:
Digits:=3:;
triginterp([11,10,17,24,32,26,23,19],x=0..21.0) |
| | 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 | ⎞
⎠ |
| | | | | | | | | |
|