複素フーリエ級数 その4

y(t)= \cos t \cos mt, y(t+2π)=y(t) のフーリエ級数展開。(周期T=2π)
有周波数f0=1/T=1/2π。

以下のように式変形する。
f:id:seinzumtode:20210615035028p:plain
積和公式
f:id:seinzumtode:20210615035014p:plain
したがって
f:id:seinzumtode:20210615035033p:plain


N=m+1で完全に元の波を再現できる。
以下はm=20の例。N=19では再現できないが、N=21で完全に復元できる。
f:id:seinzumtode:20210615034956p:plain

clear; close all; clc;

T=2*pi;
f0=1/T;
dt=0.01;
t=-T/2:dt:T/2;

m=20;
f=@(t) cos(t).*cos(m*t);
y=f(t);
plot(t,y,'DisplayName','original');
hold on;

syms x;
x2 = cos(x)*cos(m*x);
c = @(n) 1/T*int(x2*exp((-1j*2*pi*f0*n)*x),-T/2,T/2);
c = @(n) ;
c0 = c(0);

nmaxs=[19,21];
for idx=1:length(nmaxs)
    nmax = nmaxs(idx);
    ft=fourier_series_complex(t,f0,c0,c,nmax);
    plot(t,ft,'DisplayName',sprintf('N=%d',nmax));
end
legend();

big;

function ft=fourier_series_complex(t,f0,c0,c,nmax)
ft = 0;
for n=-nmax:nmax
    if n==0
        cn = c0;
    else
        cn = c(n);
    end
    ft = ft + cn*exp(1j*(2*pi*f0*n)*t);
end
end