Odd Extensions of a function

the original function is defined on [0,L] with L=3:

Clear[f,L];
f[t_] := t /; 0 <= t < 1
f[t_] := (2 - t) /; 1 <= t <= 3
L=3;

Sine series

calculate the Fourier sine coefficients mechanically

For sine series, we integrate  f(t) sin(n pi t/L) on [0,L], divide by L, and double. 

This is equivalent to integrating the extended function fo(t) against sin(n pi t/L) on [-L ,L] and dividing by L.  We define fo below.  Notice that we do not really need fo at all.

2/L((∫_0^1)(t Sin[n π t/L])\[DifferentialD]t + (∫_1^3)((2-t)Sin[n π t/L])\[DifferentialD]t)

Together[%]

Clear[b];
b[n_]=((2 (-n π Cos[((n π)/3)]+2 n π Cos[((n π)/3)] Cos[((2 n π)/3)]+3 Sin[((n π)/3)]-6 Cos[((2 n π)/3)] Sin[((n π)/3)]))/((n^2) (π^2)))

There does not appear to be a "nice" pattern...

Table[{n,b[n]},{n,1,16}]

Clear[PartialSineSum];
PartialSineSum[t_,m_]:= Sum[b[n] Sin[n π t/L],{n,1,m}]

PartialSineSum[t,4]

Plot[PartialSineSum[t,4],{t,0,L}]

Plot[PartialSineSum[t,4],{t,-10,10}]

Plot[PartialSineSum[t,8],{t,-10,10}]

an odd  extension on [-L,L]

Clear[f0,p1, p3];
fo[t_]:=f[t]/; 0≤t≤L
fo[t_]:=-f[-t]/; -L≤t<0
p1 = Plot[f[t],{t,0,L}]
p3=Plot[fo[t],{t,-L,L}]

See how the extension fits the original function on the original subinterval?  Here are a few ways to show the plots together...

Plot[{f[t], fo[t]},{t,-L,L},PlotStyle->{{Red,Thick},Blue}]

Show[{p1,p3}]

Show[{p1,p3},PlotRange->{-L,L}]

the Fourier cosine series fits the even extension

Plot[{PartialSineSum[t,8],fo[t]},{t,-L,L}]

an odd periodic extension

Clear[fOddPeriodic,x];
fOddPeriodic[x_]:= f[x] /;(0≤x<L)
fOddPeriodic[x_]:=-f[-x] /;(-L≤x < 0)
fOddPeriodic[x_]:= fOddPeriodic[x-2*L * Sign[x]]/; ((x <-L)||(x >L ))

Plot[fOddPeriodic[t],{t,-2L,2L}]

Plot[fOddPeriodic[t],{t,-5L,5L}]

Plot[PartialSineSum[t,8],{t,-5L,5L}]

Plot[{PartialSineSum[t,8],fOddPeriodic[t]},{t,-5L,5L}]

Plot[{PartialSineSum[t,16],fOddPeriodic[t]},{t,-2L,2L}]

TO ACTIVATE THE CELL BELOW, change its style to "input".  I suggest you copy, paste, and change the copy.  Then you can delete the entire piece that is dynamic and retain the command form reference.

Manipulate[Plot[{fOddPeriodic[t], PartialSineSum[t, n]}, {t, -r*L, r*L}],
 {{n, 4, "number of series terms"}, 1, 10, 2},
 {{r, 1, "number of periods"}, 1, 3, 1}]