Fourierov polinom

<< Graphics`FilledPlot`

L = 1;
f[x_] := If[x < L/2, 2  x/L, 2 - 2  x/L]
slf = Plot[f[x], {x, 0, L}];

n = 4;
a0 = (2/L) 
          Integrate[f[x], {x, 0, L}];
a = 
        Table[(2/L) Integrate[f[x] Cos[2  k Pi x/L], {x, 0, L}], {k, 
            n}];
b = 
        Table[(2/L) Integrate[f[x] Sin[2  k Pi x/L], {x, 0, L}], {k, 
            n}];
Print["a0=", a0, "  a=", MatrixForm[a], "   b=", 
      MatrixForm[b]]
F[x_] := 
      a0/2 + Sum[
          a[[k]] Cos[2  k Pi x/L] + 
            b[[k]] Sin[2  k Pi x/L], {k, 
            n}]
slF = 
        Plot[F[x], {x, 0, L}, 
          DisplayFunction -> Identity];
sl1 = 
        Show[slf, slF, 
          DisplayFunction -> Identity];
sl2 = 
        FilledPlot[{f[x], F[x]}, {x, 0, L}, 
          DisplayFunction -> Identity];
Show[GraphicsArray[{sl1, sl2}], 
        DisplayFunction -> $DisplayFunction];