N = 3;
n = 1:N;

%

an = (2 + 2 * (1 - n * pi) .* sin(pi * n) + 2 * (1 - n * pi) .* cos(pi * n)) ./ (n.^2 * pi^2) - 2 * sin(n * pi) ./ (pi * n)

%

an = 4 * (2 * sin(pi * n / 2).^2 - (pi * n .* sin(pi * n)) / 2) ./ (n.^2 * pi^2)

%

wn = 2 * pi * n

%

t = (-2:0.002:2)';

%

y = sum(an .* cos(wn .* t), 2)

%

plot(t, y)

%

syms t n

%

an = 2 * int((4 * t + 1) * cos(2 * pi * n * t), t, -0.5, 0) + 2 * int((-4 * t + 1) * cos(2 * pi * n * t), t, 0, 0.5)