フーリエ級数から導くライプニッツの公式¶
ライプニッツ級数
$$ \frac{\pi}{4}=1-\frac13+\frac15-\frac17+\cdots $$
は、のこぎり波$f(x)=x$のフーリエ級数に$x=\pi/2$を代入すると 得られます。このNotebookでは、代入する前にフーリエ係数を 記号的に導出します。
のこぎり波とその係数¶
$f$は奇関数なので、正弦項だけが現れます。
$$ x=\sum_{k=1}^{\infty}b_k\sin(kx),\qquad b_k=\frac1\pi\int_{-\pi}^{\pi}x\sin(kx)\,dx. $$
declare symbol x, n : MathValue
def f (x : MathValue) : MathValue := x
def cosinePrimitive (k : MathValue) : MathValue :=
x * sin (k * x) / k + cos (k * x) / k^2
def sinePrimitive (k : MathValue) : MathValue :=
(- x) * cos (k * x) / k + sin (k * x) / k^2
def cosineCoefficients : [MathValue] :=
map
(\k ->
let primitive := cosinePrimitive k
in (substitute [(x, π)] primitive - substitute [(x, - π)] primitive) / π)
nats
def sineCoefficients : [MathValue] :=
map
(\k ->
let primitive := sinePrimitive k
in (substitute [(x, π)] primitive - substitute [(x, - π)] primitive) / π)
nats
take 10 sineCoefficients
フーリエ級数の各項¶
次にEgisonで、各係数と対応する基底関数を組み合わせます。
def fourierTerms : [MathValue] :=
map (\(k, b) -> b * sin (k * x)) (zip nats sineCoefficients)
take 10 fourierTerms
$x=\pi/2$での値¶
偶数次の調波は0になり、奇数次の調波は符号が交互に変わります。 次の厳密な4周期のパターンを記述します。
$$ \sin(k\pi/2)=1,0,-1,0,\ldots $$
そのうえでフーリエ級数の各項を2で割ります。したがって恒等式 $\pi/2=2(1-1/3+1/5-\cdots)$から、求める級数が得られます。
def sinAtHalfPi (k : Integer) : MathValue :=
if isEven k
then 0
else (-1) ^ (i.quotient (k - 1) 2)
def leibnizTerms : [MathValue] :=
map
(\(k, b) -> b * sinAtHalfPi k / 2)
(zip nats sineCoefficients)
take 10 leibnizTerms
0でない成分を読むと$1,-1/3,1/5,-1/7,\ldots$が得られ、その 無限和は$\pi/4$です。間に現れる0は、$\pi/2$で消える偶数次の フーリエモードに対応しています。