6.26.4 An exercise with fft
Given temperatures T at time t, in degrees Celcius:
t | 0 | 3 | 6 | 9 | 12 | 15 | 19 | 21 |
T | 11 | 10 | 17 | 24 | 32 | 26 | 23 | 19 |
What was the temperature at 13h45 ?
Here N=8=2*m. The interpolation polynomial is
p(t)= | | p−m(exp(−2i | | )+ exp(2i | | ))+
| | pk exp(2i | | )
|
and
Input:
q:=1/8*fft([11,10,17,24,32,26,23,19])
Output:
| | 20.25,−4.48115530061+1.72227182413 i,0.375+0.875i, | | | | | | | | | |
| −0.768844699385+0.222271824132, i,0.5, | | | | | | | | | |
| −0.768844699385−0.222271824132, i, | | | | | | | | | |
| 0.375−0.875i, −4.48115530061−1.72227182413i | ⎤
⎦ |
| | | | | | | | | |
|
hence:
-
p0=20.25
- p1=−4.48115530061+1.72227182413i=p−1,
- p2=0.375+0.875i=p−2,
- p3=−0.768844699385+0.222271824132i=p−3,
- p4=0.5
Indeed
q=[q0,… qN−1]=[p0,..p | | ,p | | ,..,p−1]= | | FN([y0,..yN−1])= | |
|
Input:
pp:=[q[4],q[5],q[6],q[7],q[0],q[1],q[2],q[3]]
Here, pk=pp[k+4] for k=−4…3.
It remains to compute the value of the interpolation polynomial at point
t0=13.75=55/4.
Input:
t0(j):=exp(2*i*pi*(13+3/4)/24*j) |
T0:=1/2*pp[0]*(t0(4)+t0(-4))+sum(pp[j+4]*t0(j),j,-3,3) |
evalf(re(T0))
|
Output:
The temperature is predicted to be equal to 29.49 degrees Celsius.
Remark.
Using the Lagrange interpolation polynomial (the polynomial is not
periodic):
Input:
l1:=[0,3,6,9,12,15,18,21] |
l2:=[11,10,17,24,32,26,23,19] |
subst(lagrange(l1,l2,13+3/4),x=13+3/4) |
evalf(ans())
|
Output: