f(t)=πt-t², 0≤t≤π. L=π. I assume you are referring to the Fourier series.
SINE HALF-RANGE
f(x)=∑bₙsin(nπx/L), where bₙ=(2/L)∫f(x)sin(nπx/L)dx, for 0≤x≤L and n>0 an integer.
Replacing x with t and L with π:
bₙ=(2/π)∫(πt-t²)sin(nt)dt, for 0≤t≤π and n>0.
So we just need to consider the integral for n>0.
Partial integration:
u=πt-t², du=π-2t, dv=sin(nt)dt, v=-cos(nt)/n.
Let I=∫(πt-t²)sin(nt)dt, then:
I=-(πt-t²)cos(nt)/n+(1/n)∫(π-2t)cos(nt)dt,
I=-(πt-t²)cos(nt)/n+(π/n²)sin(nt)-(2/n)∫tcos(nt)dt.
Let J=∫tcos(nt)dt, then using partial integration again:
u=t, du=dt, dv=cos(nt)dt, v=sin(nt)/n,
J=tsin(nt)/n-(1/n)∫sin(nt)dt=tsin(nt)/n+(1/n²)cos(nt),
I=-(πt-t²)cos(nt)/n+(π/n²)sin(nt)-(2J/n),
I=-(πt-t²)cos(nt)/n+(π/n²)sin(nt)-(2/n)(tsin(nt)/n+(1/n²)cos(nt)).
Therefore bₙ=2I/π,
bₙ=(2/π)(-(πt-t²)cos(nt)/n+(π/n²)sin(nt)-(2/n)(tsin(nt)/n+(1/n²)cos(nt))), before applying the limits.
For the upper limit π, all the sines are zero and the cosines alternate between -1 (n odd) and 1 (n even).
For the lower limit 0, all the sines are zero and cosines are 1. Note that πt-t²=0 when t=0 or π.
These limits eliminate many terms.
When n is odd: bₙ=(2/π)(2/n³)=4/(πn³) for the upper limit.
When n is even: bₙ=-4/(πn³) for the upper limit, which can be written: bₙ=(-1)ⁿ⁺¹(4/(πn³)).
The lower limit is -4/(πn³), whether n is even or odd. Therefore the bₙ=0 for even n, and bₙ=8/(πn³) for odd n. We can replace n with 2n+1 to designate odd integers for n≥0.
b2n+1=8/((2n+1)³π)
This gives us f(t)=8sin(t)/π+8sin(3t)/(27π)+8sin(5t)/(125π)+…
COSINE HALF-RANGE
Cosine half-range expansion is similarly derived, where cos replaces sin in the sum and integral for the coefficients:
f(t)=πt-t², 0≤t≤π. L=π.
f(x)=a₀+∑aₙcos(nπx/L), where aₙ=(2/L)∫f(x)cos(nπx/L)dx, for 0≤x≤L and n>0 an integer.
a₀=(1/L)∫f(x)dx for 0≤x≤L.
Replacing x with t and L with π:
a₀=(1/π)∫(πt-t²)dt=(1/π)(πt²/2-t³/3) for 0≤t≤π and n≥0, aₙ=(2/π)∫(πt-t²)cos(nt)dt, for 0≤t≤π and n>0.
So a₀=π²/6.
Now we just need to consider the integral for n>0.
Partial integration:
u=πt-t², du=π-2t, dv=cos(nt)dt, v=sin(nt)/n.
Let I=∫(πt-t²)cos(nt)dt, then:
I=(πt-t²)sin(nt)/n-(1/n)∫(π-2t)sin(nt)dt=(πt-t²)sin(nt)/n-(π/n²)cos(nt)+(2/n)∫tsin(nt)dt.
Let J=∫tsin(nt)dt, then using partial integration again:
u=t, du=dt, dv=sin(nt)dt, v=-cos(nt)/n,
J=-tcos(nt)/n+(1/n)∫cos(nt)dt=-tcos(nt)/n+(1/n²)sin(nt),
I=(πt-t²)sin(nt)/n-(π/n²)cos(nt)-(2J/n)=(πt-t²)sin(nt)/n-(π/n²)cos(nt)-(2/n)(-tcos(nt)/n+(1/n²)sin(nt)).
Therefore aₙ=2I/π,=(2/π)((πt-t²)sin(nt)/n-(π/n²)cos(nt)-(2/n)(-tcos(nt)/n+(1/n²)sin(nt))), before applying the limits. For the upper limit π, all the sines are zero and the cosines alternate between -1 (n odd) and 1 (n even).
For the lower limit 0, all the sines are zero and cosines are 1. Note that πt-t²=0 when t=0 or π. These limits eliminate many terms.
When n is odd: aₙ=(2/π)(π/n²-2π/n²)=-2/n² for the upper limit; when n is even: aₙ=(2/π)(-π/n²+2π/n²)=2/n² for the upper limit.
The lower limit is -2/n², whether n is even or odd. Therefore aₙ=0 for odd n, and aₙ=4/n² for even n. We can replace n with 2n to designate even integers for n>0.
a2n=1/n² with a₀=π²/6 (unchanged). This gives us f(t)=π²/6+cos(2t)+cos(4t)/4+cos(6t)/9+cos(8t)/16+…