> restart; assume 0 ! n ; Fourier series for the example we did in class: f(x) = x2 on the interval x∈ (-π..π) [To do any other function, just change the definition here.] > f d x/x2 ; f := x/x2 (1) > plot f x , x =K2 p ..2 p ; 30 20 10 K2 p 3p 2 K Kp 0 p 2 K p 2 p 3p 2 2p x Of course, Maple may be used to calculate the coefficients: > a d n/ 1 $ int f x $cos n$x , x =Kp ..p ; p p f x cos n x dx a := n/ Kp p (2) > b d n/ 1 $ int f x $sin n$x , x =Kp ..p ; p p f x sin n x dx b := n/ Kp p (3) The b(n) are all zero, as f(x) is even: > eval b n ; 0 (4) Lets do a0 separately, to be sure not to divide by zero: > a0 d 1 $int f x , x =Kp ..p ; p a0 := 2 2 p 3 Now calculate the Nth partial sum, that is the sum of the Fourier series up to the Nth term: > a0 > ps d N, x / C sum 'a n $cos n$x C b n $sin n$x ', 'n = 1 ..N' ; 2 1 ps := N, x / a0 C sum 'a n cos n x C b n sin n x ', 'n = 1 ..N' 2 (5) (6) Here are the 4th and 5th partial sums of the series: > ps 4, x ; 1 2 4 1 p K 4 cos x C cos 2 x K cos 3 x C cos 4 x 3 9 4 > ps 5, x 1 2 4 1 4 p K 4 cos x C cos 2 x K cos 3 x C cos 4 x K cos 5 x 3 9 4 25 And now the graphs; we look at partial sums with N getting larger. > > plot ps 1, x , f x , x =K2 p ..2 p, y =K1 ..10 ; (7) (8) 10 8 6 y 4 2 K2 p 3p 2 K Kp p 2 K 0 p 2 p x > plot ps 2, x , f x , x =K2 p ..2 p, y =K1 ..10 3p 2 2p 10 8 6 y 4 2 K2 p 3p 2 K Kp p 2 K 0 p 2 p x > plot ps 3, x , f x , x =K2 p ..2 p, y =K1 ..10 3p 2 2p 10 8 6 y 4 2 K2 p 3p 2 K Kp p 2 K 0 p 2 p x > plot ps 4, x , f x , x =K2 p ..2 p, y =K1 ..10 3p 2 2p 10 8 6 y 4 2 K2 p 3p 2 K Kp p 2 K 0 p 2 p x > plot ps 8, x , f x , x =K2 p ..2 p, y =K1 ..10 3p 2 2p 10 8 6 y 4 2 K2 p 3p 2 K Kp p 2 K 0 p 2 p x > plot ps 12, x , f x , x =K2 p ..2 p, y =K1 ..10 3p 2 2p 10 8 6 y 4 2 K2 p 3p 2 K Kp p 2 K 0 p 2 p x > plot ps 20, x , f x , x =K2 p ..2 p, y =K1 ..10 3p 2 2p 10 8 6 y 4 2 K2 p 3p 2 K Kp p 2 K 0 p 2 p 3p 2 2p x By the Convergence Theorem, the series converges to f(x) at points of continuity in the interval x∈(-π,π). The series is periodic with period 2π. As there are no discontinuities, there are no jumps (and the convergence is rapid!) > plot ps 50, x , x =K5 p ..5 p, scaling = constrained 9 7 5 3 1 K5 p K4 p K3 p K2 p 0 Kp p 2p 3p 4p 5p x Now let's do the Half-Range Sine Series for f(x)=x2 2 > B d n/ $ int f x $sin n$x , x = 0 ..p ; p p 2 B := n/ f x sin n x dx 0 (9) p > pss d N, x / sum 'B n $sin n$x ', 'n = 1 ..N' ; pss := N, x /sum 'B n sin n x ', 'n = 1 ..N' > eval B n ; 2 2 2 K 2 cos p n~ C n~2 cos p n~ p K 2 n~ sin p n~ p K > plot (10) p n~3 pss 25, x , pss 15, x , f x , x =K2 p ..2 p, y =K12 ..12 ; (11) 10 y 5 K2 p 3p 2 K Kp 0 p 2 K p 2 p x K5 K10 3p 2 2p
© Copyright 2025 Paperzz