the fourier series representation of FS f = a0 + sigma(n=1->inf) an*cos(n*pi*x/L) + bn*sin(n*pi*x/L)
where a0 = 1/2L * int(f(x)dx) from -L to L
where an = 1/L* int(f(x)*cos(n*pi*x/L)dx) from - L to L
where bn = 1/L* int(f(x)*sin(n*pi*x/L)dx) from -L to L
i assume you can do these integrations, they just need integration by parts.
basically, what you're doing is taking a function, and making it repeat by adding up cosine and sines that have certain coefficients that make them look like a repeated version of the function you're trying to make periodic.. if you could add up an infinite number of them, you'd have a perfect representation. unfortunately, you cannot, so you may experience the Gibb's phenomenom at discontinuities.