# Chebyshev Polynomial

Polynomials related to trigonometry.

https://en.wikipedia.org/wiki/Chebyshev_polynomials

# 1 First Kind

Tn(cos(t))=cos(nt)T_n(\cos(t)) = \cos(n t)

with

T0(x)=1T_0(x) = 1 T1(x)=xT_1(x) = x Tn+2(x)=2xTn+1(x)−Tn(x)T_{n+2}(x) = 2 x T_{n+1}(x) - T_n(x)

# 2 Second Kind

Un(cos(t))sin(t)=sin((n+1)t)U_n(\cos(t)) \sin(t) = \sin((n + 1) t)

with

U0(x)=1U_0(x) = 1 U1(x)=2xU_1(x) = 2 x Un+2(x)=2xUn+1(x)−Un(x)U_{n+2}(x) = 2 x U_{n+1}(x) - U_n(x)

# 2.1 Sawtooth

Making a bandlimited sawtooth waveform:

double t = INPUT;
double X, Y;
sincos(2 * M_PI * t, &Y, &X);
double U0 = 1;
double U1 = 2 * X;
double saw = 0;
for (int i = 1; i <= HARMONICS; ++i)
{
  saw += (2 * (i & 1) - 1) * U0 * Y / i;
  double U2 = (2 * X) * U1 - U0;
  U0 = U1; U1 = U2;
}
OUTPUT = saw * (2 / M_PI));

Exercise: make number of harmonics depend on sample rate and rate of change of phase input.