チェビシェフ多項式の係数の計算

clear; close all;

syms w;
chebyshev = @(c1,c0) 2*w*c1 - c0;
c0 = 1;
c1 = w;
cs = [c0 c1];
for n=2:10
  cn_prev = cs(n-1);
  cn = cs(n);
  cn_next = chebyshev(cn, cn_prev);
  cs(end+1) = cn_next;
end

figure();
hold on;
for n=1:4
    cnw = cs(n+1);
    x = -1:0.05:1;
    y = subs(cnw, w, x);
    plot(x,y,'DisplayName',sprintf('n=%d',n));
end
legend();

figure();
hold on;
for n=5:7
    cnw = cs(n+1);
    x = -1:0.05:1;
    y = subs(cnw, w, x);
    plot(x,y,'DisplayName',sprintf('n=%d',n));
end
legend();


for idx=1:length(cs)
    c = cs(idx);
    coef = flip(coeffs(c,'All'));
    coef
end

big;

実行結果

coef =
1
coef =
[0, 1]
coef =
[-1, 0, 2]
coef =
[0, -3, 0, 4]
coef =
[1, 0, -8, 0, 8]
coef =
[0, 5, 0, -20, 0, 16]
coef =
[-1, 0, 18, 0, -48, 0, 32]
coef =
[0, -7, 0, 56, 0, -112, 0, 64]
coef =
[1, 0, -32, 0, 160, 0, -256, 0, 128]
coef =
[0, 9, 0, -120, 0, 432, 0, -576, 0, 256]
coef =
[-1, 0, 50, 0, -400, 0, 1120, 0, -1280, 0, 512]