数学のブログ

フーリエ級数展開 三角関数、正弦、加法定理、倍角

Pythonで学ぶフーリエ解析と信号処理 (神永 正博)(著)、コロナ社)の第2章(フーリエ級数展開)、章末問題2-15の解答を求めてみる。

a n = 1 π - π π x ( t ) cos n t dt
= 1 π 0 π sin t cos n t dt
= 1 π 0 π sin ( 1 + n ) t + sin ( 1 - n ) t 2 dt
= 1 π 0 π sin ( n + 1 ) t - sin ( n - 1 ) t 2 dt
n 1

のとき、

a n = 1 2 π [ - 1 n + 1 cos ( n + 1 ) t + 1 n - 1 cos ( n - 1 ) t ] 0 π
= 1 2 π ( - 1 n + 1 cos ( n + 1 ) π + 1 n - 1 cos ( n - 1 ) π + 1 n + 1 - 1 n - 1 )
= 1 2 π ( - ( - 1 ) n + 1 n + 1 + ( - 1 ) n - 1 n - 1 + 1 n + 1 - 1 n - 1 )
= 1 2 π - ( - 1 ) n - 1 n + 1 + ( - 1 ) n - 1 n - 1 + 1 n + 1 - 1 n - 1
= 1 2 π - ( - 1 ) n - 1 n + ( - 1 ) n - 1 + ( - 1 ) n - 1 n + ( - 1 ) n - 1 + n - 1 - n - 1 n 2 - 1
= 1 2 π 2 ( - 1 ) n - 1 - 2 n 2 - 1
= ( - 1 ) n - 1 - 1 π ( n 2 - 1 )

また、

a 1 = 1 π 0 π sin 2 t 2 dt = 1 4 π [ - cos 2 t ] 0 π = 0
b n = 1 π - π π x ( t ) sin n t dt
= 1 π 0 π sin t sin n t dt
= 1 π 0 π cos ( 1 - n ) t - cos ( 1 + n ) t 2 dt
= 1 π 0 π cos ( n - 1 ) t - cos ( n + 1 ) t 2 dt
n 1

のとき、

b n = 1 2 π [ sin ( n - 1 ) t n - 1 - sin ( n + 1 ) t n + 1 ] 0 π = 0

また、

b 1 = 1 π 0 π cos 0 - cos 2 t 2 dt = 1 2 π [ t - sin 2 t 2 ] 0 π = 1 2

よって、

x ( t ) a 0 2 + n = 1 ( a n cos n t + b n sin n t )
= 1 π + n = 2 ( - 1 ) n - 1 - 1 π ( n 2 - 1 ) cos n t + 1 2 sin t
= 1 π + 1 π n = 2 ( - 1 ) n - 1 - 1 n 2 - 1 cos n t + 1 2 sin t

コード(Python)

#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt

print('2-15.')

t = np.linspace(-np.pi, np.pi, 10000)


def f(t):
    if t < 0:
        return np.sin(0)
    return np.sin(t)


def partialsum(t, n):
    return 1 / np.pi + \
        1 / np.pi * sum(((-1) ** (k - 1) - 1) / (k ** 2 - 1) * np.cos(k * t)
                        for k in range(2, n + 1)) + \
        np.sin(t) / 2


xs = np.vectorize(f)(t)
for n in range(10):
    plt.plot(t, xs)
    plt.plot(t, partialsum(t, n))
    plt.legend(['x(t)', f'n = {n}'])
    plt.savefig(f'sample5_{n}')
    plt.show()

入出力結果

% ./sample5.py
2-15.
%