数学のブログ

フーリエ級数展開 三角関数、余弦、実数倍角、無限級数の和

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

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

よって、

cos a t sin a π π a + 2 π n = 1 a ( - 1 ) n - 1 sin a π n 2 - a 2 cos n t
1 = sin a π π a + 2 π n = 1 a ( - 1 ) n - 1 sin a π n 2 - a 2
n = 1 ( - 1 ) n - 1 n 2 - a 2 = π 2 a ( sin π a ) ( 1 - sin π a π a ) = π 2 a ( 1 sin π a - 1 π a )
cos a π = sin π a π a + 2 π n = 1 a ( - 1 ) n - 1 sin π a n 2 - a 2 ( - 1 ) n
cos π a = sin π a π a - 2 a ( sin π a ) π n = 1 1 n 2 - a 2
n = n 1 n 2 - a 2 = π 2 a ( sin π a ) ( sin π a π a - cos π a ) = π 2 a ( 1 π a - 1 tan π a )

コード(Python)

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

print('2-18.')


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


vectorized = np.vectorize(partialsum)
t = np.linspace(-np.pi, np.pi, 10000)
n = 5
for i in range(5):
    a = random.random() * 5
    print(f'a = {a}')
    fig = plt.figure()
    for m in range(1, n + 1):
        ax = fig.add_subplot(n, 1, m)
        ax.plot(t, np.cos(a * t))
        ax.set_ylim(-2, 2)
        ax.plot(t, vectorized(t, m, a))
    plt.savefig(f'sample8_{i}.png')
    plt.show()

入出力結果

% ./sample8.py
2-18.
a = 2.552785311478355
a = 2.4544664267404053
a = 4.999708433105535
a = 2.037236920387312
a = 2.7287739971046343
%