Even Extensions of a function

You may change 
the right endpoint L of the interval [0, L],
the function definition, 
the number of terms to be calculated in the Fourier cosine series, 
and the maximum number of periods to show.

Clear[f,L, numTerms, numPeriods];
f[t_] := t /; 0 <= t < 1
f[t_] := t^2+2 /;1 <= t < 3/2
f[t_] := (2 - t) /; 3/2 <= t <= 3
L=3;
numTerms = 10;
numPeriods = 5;


Clear[a];
a[0]=2/L NIntegrate[f[x],{x,0,L}];
Table[a[n]=2/L NIntegrate[f[x]Cos[n π x/L],{x,0,L}],{n,1,numTerms}];
Clear[PartialCosineSum,t,n,m]
PartialCosineSum[t_,m_]:= a[0]/2 + Sum[a[n] Cos[n π t/L],{n,1,m}]
Print["A partial sum for the Fourier cosine series"]
PartialCosineSum[t,numTerms]
Plot[{PartialCosineSum[t,numTerms],f[t]},{t,0,L},PlotStyle->{Blue,{Red,Thickness[0.01]}}, PlotLabel->"Original f in red, fit by the partial Fourier series"]
Clear[fEvenPeriodic,x];
fEvenPeriodic[x_]:= f[x] /;(0≤x<L)
fEvenPeriodic[x_]:=f[-x] /;(-L≤x < 0)
fEvenPeriodic[x_]:= fEvenPeriodic[x-2*L * Sign[x]]/; ((x <-L)||(x >L ))
Manipulate[Plot[{fEvenPeriodic[t],PartialCosineSum[t,n]},{t,-r*L,r*L}],{{n,4,"number of series terms"},1,numTerms,1},{{r,2,"number of periods"},1,numPeriods,1}]