# Discontinuity in Fourier sine series for vibrating string

In physics class we learned that any string vibration with two fixed endpoints can be written as a superposition of normal modes, where the shape of each normal mode is given by $y(x)=A_n\sin(nx)$. As I understand it, this means that any continuous function with fixed endpoints can be written as a series of only sines.

Then, I thought of the function $$y(x,0)=\cos(x)-\cos(2x),$$ which is fixed at $x=0$ and $x=2\pi$, and wondered about the Fourier expansion for this. The general Fourier expansion allows both cosines and sines, so obviously the general series is given by the function itself. But since the normal modes are given by sine functions, I'm guessing that I'd have to find an equivalent Fourier series in terms of only sines.

I used mathematica to find the Fourier sine series (20 terms) and plotted it, and I got a weird discontinuity. Does this mean that it's just impossible to expand this function properly? What does this mean physically? I'm starting to think that I fundamentally misunderstand something, but I can't figure out what I'm doing wrong. Any help would be appreciated!

You can think of a Fourier sine series this way: Given some arbitrary function $f(x)$ defined on the interval $[0,L]$, you can always create an odd function defined on the interval $[-L,L]$ like this:

$$g(x):=\cases{-f(-x) & x \in [-L,0) \\ 0 & x=0 \\ f(x) & x\in (0,L] }$$ (Here I've chosen $L=\pi$, and haven't worried about the point at $x=0$)

This may result in a step discontinuity if $f(0)\neq 0$, but remember that step discontinuities are not the end of the world in Fourier analysis.

From here, you take $g(x)$, which is odd and defined on $[-L,L]$, and copy-and-paste it over the whole real line: This is the function to which your Fourier sine series converges (pointwise): The problem that you are running into is actually quite simple - your $L$ is equal to $\pi$, so the function your sine series is converging to is this: So the solution to your problem is easy - just make $L=2\pi$ instead of $\pi$. You can do this by modifying the FourierParameters option:

FourierSinSeries[ ... ,FourierParameters->{1,0.5}]