Fourier sine series for f(x)=x on [0,1]

Integrate[x Sin[k Pi x],{x,0,1}]

Simplify[%, Assumptions->Element[k,Integers]]

B[k_]=2*%

Plot[Sum[B[k]Sin[k Pi x],{k,1,400}],{x,-3,3}]

Fourier cosine series for f(x)=x on [0,1]

Integrate[x Cos[k Pi x],{x,0,1}]

Simplify[%, Assumptions->Element[k,Integers]]

A[k_]=2*%

Integrate[x ,{x,0,1}]

A[0]=2*%

Plot[A[0]/2+Sum[A[k]Cos[k Pi x],{k,1,100}],{x,-3,3}]