Trap rule error in periodic functions Any function that has all derivatives at its beginning, t=0, equal to all derivatives at its end, t=T, can be expanded as a periodic function. A periodic function can always be expanded as f (t ) c j e 2 i jt T (1) j 0 Note that cj is complex and that f (t T ) c j e 2 i j t T T j 0 c j e 2 i j e 2 i j t / T f (t ) (2) j 0 Since the first exponential is always 1. The integral from 0 to T of f is T T e2 i j 1 2 i j t / T (3) f ( t ) dt c e dx c T c0T j j 0, j 0 2 i j j 0 j 0 0 The value of the integral is given by the c0 term alone. All other terms in the expansion integrate to zero. 1d 0 Let h T / N ; tk h k so that the midpoint trap rule approximation to this integral is 2 k 1d 0 / 2 T k N N k N 2 i j k T T k N 2 i j N T 2 i j tk / T ij f ( t ) dt c h e c 1 c e c T c e e N j 0 j 0 j 0 N k 1 N j 1 k 1 N j 1 j 0 k 1 k 1 (4) Note the interchange of summation orders. Let T f (t )dt c0T 0 T N k N j 1 k 1 c j e ij z j k zj e 2 i j N , so that (5) The last term can be written as a sum of zk and we can use the familiar relation for z1 N N 1 N 1 zj 1 k k k z j z j z j z jk 1 z j k 0 1 zj k 0 k N k 0 N 1 So that z k 0 k j Note that z j N e z jN 1 1 zj 2 i jN N (7) e2 ij 1 so that the numerator in (7) is always zero. The denominator is also zero for j=mN for which zmN e T 0 (6) 2 i mN N 1 . In this case the last sum in (5) is N so that f (t )dt c0T T cmN e imN (8) m 1 The terms that enter are not uniform. If for some accidental reason c10 = 0, 10 point integration will seem exact up to c20. Changing N from 10 to 20 will give a false accuracy reading. The correct change is from 10 to 11 or 13, Do not simply double the points.