$$
\definecolor{comment}{RGB}{203,23,206}
$$
$$
\newcommand{\norm}[1]{\left\Vert#1\right\Vert}
\newcommand{\abs}[1]{\left\vert#1\right\vert}
\newcommand{\set}[1]{\left\{#1\right\}}
\newcommand{\Comp}{\mathbb C}
\newcommand{\Real}{\mathbb R}
\newcommand{\Nat}{\mathbb N}
\newcommand{\of}[1]{\left ( #1 \right ) }
\newcommand{\To}{\rightarrow}
\newcommand{\eps}{\varepsilon}
$$
Joint Math-Physics topic: 1D Wave equation
Eugene Kritchevski and Rhys Adams, Vanier College, last updated on April 20, 2016
Setup and some generalities about functions of two variables
The motion of a vibrating string is described by a function of two variables
$$u=u(x,t)$$
Here $u$ is the transversal displacement from the equilibrium position of the string at location $x$ and at time $t$. A way to think about a fuction of two variables is to freeze one variable and see how the function depends of the other variable.
If we freeze $t$, then the graph of $y=u(x,t)$ is a snapshot of the shape of the string at time $t$. If we freeze $x$, then the function $t\to u(x,t)$ represents the transversal motion of the spring at location $x$. The applet below simulates the vibration of the string.
If we freeze $t$, then we can differentiate $u(x,t)$ with respect to $x$, treating $t$ as a constant. The resulting derivative is called the partial derivative of $u$ with repespect to $x$ and is denoted by $u_x$. Other frequently used notations are
$$u_x=\frac{\partial u}{\partial x}=\frac{\partial }{\partial x}u=\of{\frac{\partial }{\partial x}}u$$
Similarly, if we freeze $x$ and differentiante $u(x,t)$ with respect to $t$, treating $x$ as a constant, we get the partial derivative of $u$ with repespect to $t$
$$u_t=\frac{\partial u}{\partial t}=\frac{\partial }{\partial t}u=\of{\frac{\partial }{\partial t}}u$$
For example, if $u=u(x,t)=x^2t^3+\sin(x)+e^{2t}$, then $u_x=2xt^3+\cos(x)+0$ and $u_t=x^2 3t^2+0+2e^{2t}$. The function $u$ in this example is only used to illustrate the concept of partial derivatives and does not represent the vibration of a string.
The partial derivatives $u_x$ and $u_t$ are again functions of the two variables $x$ and $t$ and so we can take their partial derivatatives. The partial derivative of $u_x$ with respect to $x$ is denoted by $u_{xx}$ and represents the second derivative of $u$ with respect to $x$, treating $t$ as a constant. Another common notation for $u_{xx}$ is $\of{\frac{\partial }{\partial x}}^2u$. Similarly $u_{tt}$ is the partial derivative of $u_t$ with respect to $t$. Another common notation for $u_{tt}$ is $\of{\frac{\partial }{\partial t}}^2u$. In the previous example, we have $u_{xx}=2t^3-\sin(x)$ and $u_{tt}=x^2 6t+4e^{2t}$.
The linearity properties of derivatives, namely $(f+g)'=f'+g'$ and $(constant\cdot f)'=(constant)\cdot f'$, imply corresponding linearity properies for partial derivatives
$$\frac{\partial}{\partial x}(u+v)=\frac{\partial}{\partial x}u+\frac{\partial}{\partial x}v \qquad\textrm{ and } \qquad
\frac{\partial}{\partial x}(constant\cdot u)=constant\cdot\frac{\partial}{\partial x}u$$
$$\of{\frac{\partial}{\partial x}}^2(u+v)=\of{\frac{\partial}{\partial x}}^2u+\of{\frac{\partial}{\partial x}}^2v \qquad\textrm{ and } \qquad
\of{\frac{\partial}{\partial x}}^2(constant\cdot u)=constant\cdot\of{\frac{\partial}{\partial x}}^2u$$
and similarly for the partial derivatives with respect to $t$.
Remark: The mixed second partial derivative $u_{x,t}$ is the partial derivative derivative of $u_x$ with respect to $t$ and similarly $u_{t,x}$ is the partial deivative of $u_t$ with repect to $x$. It turns out that, for most functions, we have $u_{x,t}=u_{t,x}$. Partial derivatives are studied in greater detail in Calculus 3.
The 1D wave equation
The motion of a vibrating string is described, under various simplifying assumptions, by the
1D wave equation
$$u_{tt}=c^2 u_{xx}$$
with $$c=\sqrt{\frac{T}{\rho}}$$
where $T$ is the tension of the string and $\rho$ is the mass density. The 1D wave equation is a partial differential equation (PDE), because it involves partial derivatives.
Exercise: Check that $u=c^2t^5x^3$ is not a solution to the wave equation.
Solution: We have $u_t=c^2 5t^4x^3$, $u_{tt}=c^2 2- t^3 x^3$, $u_x=c^2 t^5 3x^2$, $u_{xx}=c^2t^5 6x$. Clearly $u_{tt}\neq c^2 u_{xx}$
Exercise: Check that $u=\sin(x-ct)$ is a solution to the wave equation.
Solution: Using the Chain rule, we have $u_t=-c\cos(x-ct)$, $u_{tt}=(-c)(-c)(-\sin(x-ct)=-c^2\sin(x-ct)$, $u_x=\cos(x-ct)$, $u_{xx}=-\sin(x-ct)$. Here it is true that $u_{tt} = c^2 u_{xx}$
The 1D wave equation can be equivalently written as
$$u_{tt}-c^2 u_{xx}=0$$
or
$$\of{\of{\frac{\partial }{\partial t}}^2 - c^2\of{\frac{\partial }{\partial x}}^2}u=0$$
We can think of $$\square=\of{\frac{\partial }{\partial t}}^2 - c^2\of{\frac{\partial }{\partial x}}^2$$ as an operator acting on $u$. The operation is
$$u\xrightarrow[]{\square} u_{tt}-c^2 u_{xx}$$ The operator $\square$ is called wave operator. Thus, the wave equation can be compactly written as
$$\square u=0$$
The operator $\square$ inherits the linearity properties of partial derivatives and it easy to check that (do it as an exercise) that
$$\square (u+v)=\square u+\square v \qquad\textrm{ and } \qquad
\square(constant\cdot u)=constant\cdot\square u$$
The linearity properties imply that any superposition of solutions or a scaling or a solution still give solutions. Indeed, if $\square u=0$ and $\square v =0$, then
$\square(u+v)=\square u+\square v =0+0=0$ and $\square (constant\cdot u)=constant\cdot \square u=constant\cdot 0=0$.
There are infinitely many solutions to the wave equation. In fact for any functions $\phi$ and $\phi$ of one variable, $u=\phi(x-ct)$ and $u=\psi(x+ct)$ are solutions.
Exercise: Verify that $u=\phi(x-ct)$ and $u=\psi(x+ct)$ are solutions to the wave equation. Explain the geometrical (and the physical) meaning of $\phi(x-ct)$ and $\psi(x+ct)$ in terms of translations of the graphs of $y=\phi(x)$ and $y=\psi(x)$.
Since the sum of two solutions is again a solution, $u=\phi(x-ct)+\psi(x+ct)$ is a solution. In fact it can be proved that all possible solutions to the wave equation are of that form.
D'Alembert's solution to the wave equation
$$u=\phi(x-ct)+\psi(x+ct)$$ is the
general solution to the wave equation.
Initial and boundary conditions, uniqueness of the solution
We will impose the boundary conditions (B.C.)
$$u(0,t)=x(L,t)=0\qquad \textrm{ for all } t$$
and the initial conditions (I.C.)
$$u(x,0)=f(x)\qquad 0\leq x\leq L$$
$$u_t(x,0)=g(x) \qquad 0\leq x\leq L$$
The B.C. mean that the string's ends are pinned at all times. The I.C. specify the initial position of the string and the initial (transversal) velocity. For consistency with the B.C., we must have $f(0)=f(L)=0$ and $g(0)=g(L)=0$. Under these required B.C. and I.C. the solution to the wave will be unique. The proof goes along the following lines. If $u$ and $v$ are two solutions then, the difference $$w=u-v$$ is a solution to the wave equation with trivial I.C.
$$w(x,0)=u(x,0)-v(x,0)=f(x)-f(x)=0\qquad 0\leq x\leq L$$
$$w_t(x,0)=u_t(x,0)-v_t(x,0)=g(x)-g(x)=0 \qquad 0\leq x\leq L$$
Physical intuition tell us that when a string start at rest and without an intial velocity, the the string will no move at all, that is $w(x,t)=0$ for all $t$ and therefore $u(x,t)=v(x,t)$ for all $t$. To make this proof rigourous, one needs to define the energy of the string and show that the energy is conserved. Then, starting from rest, we initially have zero energy, which will stay zero forever and therefore the will be no movement.
(Somewhat challenging) Exercise: The kinetic and the potential energy of the vibrating string are defined by
$$EK=\int_{0}^{L}\frac{1}{2}\rho( u_t(x,t))^2dx$$
$$EP=\int_{0}^{L}\frac{1}{2}T( u_x(x,t))^2dx$$
The total energy is the sum
$$E=EK+EP=\frac{1}{2}\int_{0}^{L}\of{\rho (u_t(x,t))^2 + T (u_x(x,t))^2} dx$$
Assume that $u$ solves the wave equation and the boundary conditions. Using integration by parts, prove that
$$\frac{dE}{dt}=0,$$
which implies that the total energy is conserved as time goes by. If in addition $E=0$ at time $t=0$, and hence at all times, prove that $u(t,x)=0$ for all $0\leq x \leq L$ and for all $t$, i.e. the string will not vibrate at all.
Knowing that a solution is unique is very comforting. We can now use any method we want (rigorous or not) to find the solution. If we find a function $u$ that solves the wave equation together with the B.C. and I.C., then our function is the correct one and there is no need to worry about having missed another solution.
D'Alembert's solution: odd periodic extensions
Consider the wave eqaution with the (B.C.)
$$u(0,t)=x(L,t)=0\qquad \textrm{ for all } t$$
and the (I.C.)
$$u(x,0)=f(x)\qquad 0\leq f(x)\leq L$$
$$u_t(x,0)=0 \qquad 0\leq f(x)\leq L$$
The initial velocity of the string is zero. This represents plucking a guitar's springs. Let us find the solution using d'Alemberts formula
$$(1)\qquad u(x,t)=\phi(x-ct)+\psi(x+ct).$$
Hopefully, the B.C. and the I.C. will tell us what $\phi$ and $\psi$ are.
Then
$$(2)\qquad u_t(x,t)=-c\phi'(x-ct)+c\psi'(x+ct)$$
Plugging in the I.C. in $(1)$ and $(2)$ gives
$$(3)\qquad \phi(x)+\psi(x)=f(x)$$
$$(4)\qquad -c\phi'(x)+c\psi'(x)=0$$
From $(4)$, we have $\phi'(x)=\psi'(x)$ and so $\phi(x)=\psi(x)+constant$. From the B.C. we have $\phi(0)=\psi(0)=0$ and therefore $constant=0$ and so
$$\psi(x)=\phi(x).$$
Then $(3)$ gives $2\phi(x)=f(x)$ and so
$$\phi(x)=\frac{1}{2} f(x).$$
The solution is then
$$u=u(x,t)=\phi(x-ct)+\psi(x+ct)=\frac{1}{2} f(x-ct)+\frac{1}{2} f(x+ct)$$
D'Alembert's solution to the wave equation with initial position and zero initial velocity
The solution to the wave equation
$$u_{tt}-c^2 u_{xx}=0$$ with $B.C.$
$$u(0,t)=x(L,t)=0\qquad \textrm{ for all } t$$
and (I.C.)
$$u(x,0)=f(x)\qquad 0\leq x\leq L$$
$$u_t(x,0)=0 \qquad 0\leq x\leq L$$
is given by
$$u=\frac{1}{2} f(x-ct)+\frac{1}{2} f(x+ct)$$
But wait a second! The function $f$ is only defined on the interval $[0,L]$. The arguments $x\pm ct$ will not be necessarily in the in the interval $[0,L]$. In fact for large enough $t$, $x\pm ct$ will for sure escape the interval $[0,L]$. In order for the solution to make sense, we need to appropriately extend the defintion of $f(x)$ ouside the interval $[0,L]$. The B.C. will tell us how to do it.
The solution
$$u(x,t)=\frac{1}{2} f(x-ct)+\frac{1}{2} f(x+ct)$$
must verify $u(0,t)=u(L,t)=0$ for all $t$. Therefore
$$0=\frac{1}{2} f(-ct)+\frac{1}{2} f(ct)$$
for all $t$ and so $$f(-ct)=-f(ct),$$ which forces $f$ to be and odd function. Also
$$0=\frac{1}{2} f(L-ct)+\frac{1}{2} f(L+ct)$$
implies (using the fact that $f$ is odd)
$$f(ct+L)=-f(L-ct)=f(-(L-ct))=f(ct-L),$$
which forces $f$ to be $2L$-periodic.
D'alembert's solution
$$u=\frac{1}{2} f(x-ct)+\frac{1}{2} f(x+ct)$$
is valid with the understandting that the definition of $f$ outside $[0,L]$ is such that $f$ is odd and $2L$-periodic.
Exercise: If we replace the I.C. $$u_t(x,0)=0 \qquad 0\leq x\leq L$$ with the more general I.C.
have the more general I.C.
$$u_t(x,0)=g(x) \qquad 0\leq x\leq L$$
Show that the d'Alembert's solution is
$$u(x,t)=\frac{1}{2} f(x-ct)+\frac{1}{2} f(x+ct)+\frac{1}{2c}\int_{x-ct}^{x+ct}g(s)ds$$
with the understanding that, as before, $f$ is odd and $2L$-periodic.
Solution by separation of variables and Fourier series
Here we take a completely different approach for solving the wave equation. We temporarily ignore the B.C., the I.C. and also d'Alembert's solution. Instead we make the observation that, in general, one of the the simplest kind of a function of two variables is a function of form
$$u(x,t)=X(x)T(t)$$
where $X$ and $T$ are functions of one variable. (Here $T$ does not mean the tension of the string anymore). Let us see if such a product function could possibly be a solution to the wave equation. We first compute the partial derivatives
$$u_{xx}=X''(x)T(t)$$
$$u_{tt}=X(x)T''(t)$$
If $u$ is a solution to the wave equation $u_{tt}=c^2 u_{xx}$, then
$$X(x)T''(t)=c^2 X''(x)T(t)$$
which, after rearranging, gives
$$\frac{X''(x)}{X(x)}=\frac{1}{c^2}\frac{T''(t)}{T(t)}.$$
Note that the left hand side is a function of $x$ only and the right hand side is a function of $t$ only. We have separated the variables. In general the equation $a(x)=b(t)$ implies that $a(x)=b(t)=constant$. Indeed taking the partial derivative with respect to $x$ gives $a'(x)=\frac{\partial}{\partial x} a(x)= \frac{\partial}{\partial x}b(t)=0$ which impplies that $a(x)=constant$. Therefore we have
$$\frac{X''(x)}{X(x)}=\frac{1}{c^2}\frac{T''(t)}{T(t)}=constant$$
Note: the possible values of the constant will turn out to be very important.
Now we must have
$$X''(x)=constant\cdot X(x),$$
that is the second derivative of $X$ is proportional to $X$. There are two classes of functions with such property:
1) exponential functions $\set{e^{\omega x},e^{-\omega x}}$
2) trigonometric functions $\set{\cos(\omega x),\sin(\omega x)}$
Exercise: 1) Check that if $X=e^{\omega x}$ or $X=e^{\omega x}$ or, more generally, $X(x)=Ae^{\omega x} + B e^{-\omega x}$ for constants $A$ and $B$, we have
$$X''(x)=\omega^2 X(x)$$
2) Check that if $X=\cos(\omega x)$ or $X=\sin(\omega x)$ or, more generally, $X(x)=A\cos(\omega x)+B \sin(\omega x)$ for constants $A$ and $B$, we have
$$X''(x)=-\omega^2 X(x)$$
The B.C. will select for us the admissible functions $X(x)$ from the above zoo of exponentials and trig functions. Since
$u(0,t)=u(L,t)=0$ for all $t$, we must have $X(0)T(t)=x(L)T(t)=0$ for all $t$. The case where $T(t)=0$ for all $0$ gives us the trivial solution $u(x,t)=0$. For nontrivial solutions we must have
$$ (*)\qquad \boxed{X(0)=X(L)=0}$$
in addition to
$$X''(x)=constant\cdot X(x)$$
Exercise: There is no non zero function of the form $X(x)=Ae^{\omega x} + B e^{-\omega x}$ such that
$x(0)=x(L)=0$.
The exponential functions are ruled out so we are left with trig functions. Since we want $X(0)=0$, we will stick with
$$X(x)=\sin(\omega x)$$
In this case
$$X''(x)=constant\cdot X(x)=-\omega^2 X(x)$$
so
$$constant=-\omega^2 < 0$$
What are the allowed values of $\omega$? We need $X(L)=0$ so
$$\sin(\omega L)=0$$
and $\omega L$ must be an integer multiple of $\pi$.
It is enough to assume that $\omega >0$. Indeed $\sin(-\omega x)=-\sin(\omega x)$, which is just a multiple of $\sin(\omega x)$ and, at the end, we will be multipling $\sin(\omega)$ by an arbitrary amplitude anyways. So the admissible $\omega$ values are given by the sequence
$$\set{\omega_1=\frac{\pi}{L}, \omega_2=\frac{2\pi}{L},\omega_3=\frac{3\pi}{L},\omega_4=\frac{4\pi}{L},\cdots}$$
or more compactly
$$\set{\omega_n=\frac{n\pi }{L}}_{n=1}^{\infty}$$
We now have a sequence of possible functions $X(x)$
$$\set{X_n(x)=\sin(\omega_n x)=\sin\of{\frac{n\pi x}{L}}}_{n=1}^{\infty}$$
Next, we examine the corresponding functions $T_n(t)$. For each $n\geq 1$, we have
$$\frac{X_n''(x)}{X_n(x)}=\frac{1}{c^2}\frac{T_n''(t)}{T_n(t)}=constant=-\omega_n^2$$
and so
$$T_n''(t)= -c^2\omega_n^2T_n(t)$$
The exponential functions will not work here because $-c^2\omega_n^2 < 0$ but for any constants $A_n$ and $B_n$, a trig function
$$T_n(t)=A_n \cos(c\omega_n t)+B_n \sin(c \omega_n t)$$
will verify the D.E. $T_n''(t)= -c^2\omega_n^2T_n(t)$.
Let us summarize what we have done so far:
For every integer $n\geq 1$, the function
$$u_n(x,t)=X_n(x)T_n(t)=\sin(\omega_n x)\of{A_n \cos(c\omega_n t)+B_n \sin(c \omega_n t)},\qquad \textrm{where } \omega_n=\frac{n\pi }{L},$$
solves the wave equation
$$u_{tt}=c^2 u_{xx}$$
with the B.C.
$$u(0,t)=u(L,t)=0$$
The function $u_n(x,t)$ is called a standing wave. One can think of it as a fixed (standing) profile function $X_n(x)$ multiplied by the oscilating amplitude $T_n(t)$. The period $\tau_n$ of the oscillation is given by
$$c\omega_n \tau_n=2\pi \Leftrightarrow \tau_n=\frac{2\pi}{c\omega_n}=\frac{2L}{cn}$$
and the frequency of the oscillation is
$$f_n=\frac{1}{\tau_n}=\frac{cn}{2L}$$
We now need to ensure that our solution also has the correct I.C.
$$u(x,0)=f(x)$$
$$\frac{\partial}{\partial t} u(x,0)=g(x)$$
We have
$$u_n(x,0)=X_n(x)T_n(0)= \sin(\omega_n x) (A_n\cdot 1+ B_n\cdot 0)=A_n \sin(\omega_n x)$$
and
$$\frac{\partial}{\partial t}u_n(x,0)=X_n(x)T_n'(0)= \sin(\omega_n x) (A_n\cdot 0+ B_n\cdot c\omega_n)=c\omega_n B_n \sin(\omega_n x)$$
In general, $u_n$ will not be a solution, except for the special case where we are given the I.C. of the form $f(x)=A_n \sin(\omega_n x)$ and $g(x)=c\omega_n B_n \sin(\omega_n x)$. To handle a more general I.C. $f(x)$ and $g(x)$, we use superposition:
The function
$$u(x,t)=\sum_{n=1}^{N} u_n(x,t)=\sum_{n=1}^{N}X_n(x)T_n(t)=\sum_{n=1}^{N} \sin(\omega_n x)\of{A_n \cos(c\omega_n t)+B_n \sin(c \omega_n t)}$$
also solves the wave equation and the B.C. You can consider $N$ to be finite at this point, but a finer analysis can show that in many cases we are allowed to have $N=\infty$. We now have the freedom to adjust the constants $A_n$ and $B_n$ hoping to satisfy the I.C.
Then we must have
$$f(x)=u(x,0)=\sum_{n=1}^{N} u_n(x,0)=\sum_{n=1}^{N}X_n(x)T_n(0)=\sum_{n=1}^{N} A_n \sin(\omega_n x)$$
$$g(x)=\frac{\partial}{\partial t}u(x,0)=\sum_{n=1}^{N} u_n'(x,0)=\sum_{n=1}^{N}X_n(x)T_n'(0)=\sum_{n=1}^{N} c\omega_n B_n \sin(\omega_n x)$$
Thus, we can solve the wave equation if we are able to represent (decompose) the function $f(x)$ as a combination of $\sin(\omega_n x)$ in the form $f(x)=\sum_{n=1}^{N} A_n \sin(\omega_n x)$ and similarly for $g$. The theory of such decompositions is called Fourier analysis (study of Fourier series). A basic result in Fourier analysis is that such decompositions are generally possible and the coefficients $A_n$ are given by the formula
$$A_n=\frac{2}{L}\int_{0}^{L}f(x)\sin(\omega_n x)\,dx$$
Similarly
$$c\omega_n B_n=\frac{2}{L}\int_{0}^{L}g(x)\sin(\omega_n x)\,dx$$
and so
$$ B_n=\frac{1}{c\omega_n}\frac{2}{L}\int_{0}^{L}g(x)\sin(\omega_n x)\,dx$$
Typically, if $N$ is a finite number the sum $\sum_{n=1}^{N} A_n \sin(\omega_n x)$ will only be an approximation to $f(x)$. The approximation will improve as $N$ gets larger. To have a true equality $f(x)=\sum_{n=1}^{N} A_n \sin(\omega_n x)$, one usually needs $N=\infty$.
Fourier sine series
Let $L>0$ be a fixed real number. For integers $m\neq n$, let
$$I_{n,m}=\int_{0}^{L}\sin(n\pi x/L)\sin( m x/L)\,dx$$
Exercise: Show that $I_{n,m}=0$ for $n\neq m$ and that $I_{n,n}=L/2$. Hint: use the trigonometric identity
$$\sin(a)\sin(b)=\frac{1}{2}\of{\cos(a-b)-\cos(a+b)}$$
Suppose that $f(x)$ is given by
$$f(x)=\sum_{n=1}^{N}c_n \sin(n\pi x/L)$$
Then we must have
$$
\begin{equation*}
\begin{split}
\int_{0}^{L} f(x) \sin(m\pi x/L)\,dx&=\int_{0}^{L} \of{\sum_{n=1}^{N}c_n \sin(n\pi x/L)} \sin(m\pi x/L)\,dx\\
&=\sum_{n=1}^{N} c_n \of{ \int_{0}^{L} \sin(n\pi x/L) \sin(m \pi x/L)\,dx} \\
&=\sum_{n=1}^{N} c_n I_{n,m} \qquad &\color{comment}\textrm{ all the terms in the sum are zero except } c_{m}I_{m,m}\\
&=c_{m} I_{m,m} \\
&=c_{m} L/2 \\
\end{split}
\end{equation*}
$$
and therefore
$$(*)\qquad c_{m}=\frac{2}{L} \int_{0}^{L} f(x) \sin(m\pi x/L)$$
The number $c_{m}$ is called the $m^{th}$ Fourier sine coefficient. If $f(x)$ is any continuous function on $[0,L]$, not necessarily of the form $f(x)=\sum_{n=1}^{N}c_n \sin(n\pi x/L)$, then we cann still compute $c_m$ by the formula $(*)$ and consider
$$F_N(x)=\sum_{n=1}^{N}c_n \sin(n\pi x/L)$$
The functions
$$\set{F_1(x),F_2(x),F_3(x),\cdots}$$ form a sequence of approximations to $f(x)$ on the interval $[0,L]$.
If the function $f$ is nice enough, for example if $f(0)=f(L)=0$ and $f'(x)$ is continuous on $[0,L]$ (except perhaps at finite number of jump discontinuities), then it can be shown that
$$\lim_{N\to\infty}F_N(x)=f(x)$$
for all $x$ in $[0,L]$. In this case, we write
$$f(x)=\sum_{n=1}^{\infty} c_n \sin(n\pi x/L)$$
The applet below illustrates convergence $F_N\to f$.