Introduction. The stream velocity \(\bar{u}\) in Cartesian coordinates is \begin{align} \bar{u} & =u\hat{\imath }+v\hat{\jmath }\nonumber \\ & =\frac{\partial \Psi }{\partial y}\hat{\imath }-\frac{\partial \Psi }{\partial x}\hat{\jmath } \tag{1} \end{align}
Where \(\Psi \) is the stream function which satisfies Laplace PDE in 2D \(\nabla ^{2}\Psi =0\). In Polar coordinates the above becomes\begin{align} \bar{u} & =u_{r}\hat{r}+u_{\theta }\hat{\theta }\nonumber \\ & =\frac{1}{r}\frac{\partial \Psi }{\partial \theta }\hat{r}-\frac{\partial \Psi }{\partial r}\hat{\theta } \tag{2} \end{align}
The solution to \(\nabla ^{2}\Psi =0\) was found under the following conditions
Using the above three conditions, the solution to \(\nabla ^{2}\Psi =0\) was derived in lecture Sept. 30, 2016, to be\[ \Psi \left ( r,\theta \right ) =c_{1}\ln \left ( \frac{r}{a}\right ) +u_{0}\left ( r-\frac{a^{2}}{r}\right ) \sin \theta \] Using the above solution, the velocity \(\bar{u}\) can now be found using the definition in (2) as follows\begin{align*} \frac{1}{r}\frac{\partial \Psi }{\partial \theta } & =\frac{1}{r}u_{0}\left ( r-\frac{a^{2}}{r}\right ) \cos \theta \\ \frac{\partial \Psi }{\partial r} & =\frac{c_{1}}{r}+u_{0}\left ( 1+\frac{a^{2}}{r^{2}}\right ) \sin \theta \end{align*}
Hence, in polar coordinates\begin{equation} \fbox{$\bar{u}=\left ( \frac{1}{r}u_0\left ( r-\frac{a^2}{r}\right ) \cos \theta \right ) \hat{r}-\left ( \frac{c_1}{r}+u_0\left ( 1+\frac{a^2}{r^2}\right ) \sin \theta \right ) \hat{\theta }$} \tag{3} \end{equation} Now the question posed can be answered. The circulation is given by\[ \Gamma =\int _{0}^{2\pi }u_{\theta }rd\theta \] But from (3) \(u_{\theta }=-\left ( \frac{c_{1}}{r}+u_{0}\left ( 1+\frac{a^{2}}{r^{2}}\right ) \sin \theta \right ) \), therefore the above becomes\[ \Gamma =\int _{0}^{2\pi }-\left ( \frac{c_{1}}{r}+u_{0}\left ( 1+\frac{a^{2}}{r^{2}}\right ) \sin \theta \right ) rd\theta \] At \(r=a\) the above simplifies to\begin{align*} \Gamma & =\int _{0}^{2\pi }-\left ( \frac{c_{1}}{a}+2u_{0}\sin \theta \right ) ad\theta \\ & =\int _{0}^{2\pi }-c_{1}-2au_{0}\sin \theta d\theta \\ & =-\int _{0}^{2\pi }c_{1}d\theta -2au_{0}\int _{0}^{2\pi }\sin \theta d\theta \end{align*}
But \(\int _{0}^{2\pi }\sin \theta d\theta =0\), hence\begin{align*} \Gamma & =-c_{1}\int _{0}^{2\pi }d\theta \\ & =-2c_{1}\pi \end{align*}
Since \(\Gamma <0\), then \(c_{1}>0\). Now that \(c_{1}\) is known to be positive, then the velocity is calculated at \(\theta =\frac{-\pi }{2}\) and then at \(\theta =\frac{+\pi }{2}\) to see which is larger. Since this is calculated at \(r=a\), then the radial velocity is zero and only \(u_{\theta }\) needs to be evaluated in (3).
At \(\theta =\frac{-\pi }{2}\)\begin{align*} u_{\left ( \frac{-\pi }{2}\right ) } & =-\left ( \frac{c_{1}}{r}+u_{0}\left ( 1+\frac{a^{2}}{r^{2}}\right ) \sin \left ( \frac{-\pi }{2}\right ) \right ) \\ & =-\left ( \frac{c_{1}}{r}-u_{0}\left ( 1+\frac{a^{2}}{r^{2}}\right ) \sin \left ( \frac{\pi }{2}\right ) \right ) \\ & =-\left ( \frac{c_{1}}{r}-u_{0}\left ( 1+\frac{a^{2}}{r^{2}}\right ) \right ) \end{align*}
At \(r=a\)\begin{align} u_{\left ( \frac{-\pi }{2}\right ) } & =-\left ( \frac{c_{1}}{a}-2u_{0}\right ) \nonumber \\ & =-\frac{c_{1}}{a}+2u_{0} \tag{4} \end{align}
At \(\theta =\frac{+\pi }{2}\)\begin{align*} u_{\left ( \frac{+\pi }{2}\right ) } & =-\left ( \frac{c_{1}}{r}+u_{0}\left ( 1+\frac{a^{2}}{r^{2}}\right ) \sin \left ( \frac{\pi }{2}\right ) \right ) \\ & =-\left ( \frac{c_{1}}{r}+u_{0}\left ( 1+\frac{a^{2}}{r^{2}}\right ) \right ) \end{align*}
At \(r=a\)\begin{align} u_{\left ( \frac{-\pi }{2}\right ) } & =-\left ( \frac{c_{1}}{a}+2u_{0}\right ) \nonumber \\ & =-\frac{c_{1}}{a}-2u_{0} \tag{5} \end{align}
Comparing (4),(5), and since \(c_{1}>0\), then the magnitude of \(u_{\theta }\) at \(\frac{\pi }{2}\) is larger than the magnitude of \(u_{\theta }\) at \(\frac{-\pi }{2}\). Which implies the stream flows faster above the cylinder than below it.
The following is sketch of periodic extension of \(e^{-x}\) from \(x=-L\cdots L\) (for \(L=1\)) for illustration. The function will converge to \(e^{-x}\) between \(x=-L\cdots L\) and between \(x=-3L\cdots -L\) and between \(x=L\cdots 3L\) and so on. But at the jump discontinuities which occurs at \(x=\cdots ,-3L,-L,L,3L,\cdots \) it will converge to the average shown as small circles in the sketch.
By definitions,\begin{align*} a_{0} & =\frac{1}{T}\int _{-T/2}^{T/2}f\left ( x\right ) dx\\ a_{n} & =\frac{1}{T/2}\int _{-T/2}^{T/2}f\left ( x\right ) \cos \left ( n\left ( \frac{2\pi }{T}\right ) x\right ) dx\\ b_{n} & =\frac{1}{T/2}\int _{-T/2}^{T/2}f\left ( x\right ) \sin \left ( n\left ( \frac{2\pi }{T}\right ) x\right ) dx \end{align*}
The period here is \(T=2L\), therefore the above becomes\begin{align*} a_{0} & =\frac{1}{2L}\int _{-L}^{L}f\left ( x\right ) dx\\ a_{n} & =\frac{1}{L}\int _{-L}^{L}f\left ( x\right ) \cos \left ( n\frac{\pi }{L}x\right ) dx\\ b_{n} & =\frac{1}{L}\int _{-L}^{L}f\left ( x\right ) \sin \left ( n\frac{\pi }{L}x\right ) dx \end{align*}
These are now evaluated for \(f\left ( x\right ) =e^{-x}\)\[ a_{0}=\frac{1}{2L}\int _{-L}^{L}e^{-x}dx=\frac{1}{2L}\left ( \frac{e^{-x}}{-1}\right ) _{-L}^{L}=\frac{-1}{2L}\left ( e^{-x}\right ) _{-L}^{L}=\frac{-1}{2L}\left ( e^{-L}-e^{L}\right ) =\frac{e^{L}-e^{-L}}{2L}\] Now \(a_{n}\) is found
\[ a_{n}=\frac{1}{L}\int _{-L}^{L}e^{-x}\cos \left ( n\frac{\pi }{L}x\right ) dx \] This can be done using integration by parts. \(\int udv=uv-\int vdu\). Let \[ I=\int _{-L}^{L}e^{-x}\cos \left ( n\frac{\pi }{L}x\right ) dx \] and \(u=\cos \left ( n\frac{\pi }{L}x\right ) ,dv=e^{-x},\rightarrow du=-\frac{n\pi }{L}\sin \left ( n\frac{\pi }{L}x\right ) ,v=-e^{-x}\), therefore\begin{align*} I & =\left [ uv\right ] _{-L}^{L}-\int _{-L}^{L}vdu\\ & =\left [ -e^{-x}\cos \left ( n\frac{\pi }{L}x\right ) \right ] _{-L}^{L}-\frac{n\pi }{L}\int _{-L}^{L}e^{-x}\sin \left ( n\frac{\pi }{L}x\right ) dx\\ & =\left [ -e^{-L}\cos \left ( n\frac{\pi }{L}L\right ) +e^{L}\cos \left ( n\frac{\pi }{L}\left ( -L\right ) \right ) \right ] -\frac{n\pi }{L}\int _{-L}^{L}e^{-x}\sin \left ( n\frac{\pi }{L}x\right ) dx\\ & =\left [ -e^{-L}\cos \left ( n\pi \right ) +e^{L}\cos \left ( n\pi \right ) \right ] -\frac{n\pi }{L}\int _{-L}^{L}e^{-x}\sin \left ( n\frac{\pi }{L}x\right ) dx \end{align*}
Applying integration by parts again to \(\int e^{-x}\sin \left ( n\frac{\pi }{L}x\right ) dx\) where now \(u=\sin \left ( n\frac{\pi }{L}x\right ) ,dv=e^{-x}\rightarrow du=\frac{n\pi }{L}\cos \left ( n\frac{\pi }{L}x\right ) ,v=-e^{-x}\), hence the above becomes\begin{align*} I & =\left [ -e^{-L}\cos \left ( n\pi \right ) +e^{L}\cos \left ( n\pi \right ) \right ] -\frac{n\pi }{L}\left ( uv-\int vdu\right ) \\ & =\left [ -e^{-L}\cos \left ( n\pi \right ) +e^{L}\cos \left ( n\pi \right ) \right ] -\frac{n\pi }{L}\left ( \overset{0}{\overbrace{\left [ -e^{-x}\sin \left ( n\frac{\pi }{L}x\right ) \right ] _{-L}^{L}}}+\frac{n\pi }{L}\int _{-L}^{L}e^{-x}\cos \left ( n\frac{\pi }{L}x\right ) dx\right ) \\ & =\left [ -e^{-L}\cos \left ( n\pi \right ) +e^{L}\cos \left ( n\pi \right ) \right ] -\frac{n\pi }{L}\left ( \frac{n\pi }{L}\int _{-L}^{L}e^{-x}\cos \left ( n\frac{\pi }{L}x\right ) dx\right ) \\ & =\left [ -e^{-L}\cos \left ( n\pi \right ) +e^{L}\cos \left ( n\pi \right ) \right ] -\left ( \frac{n\pi }{L}\right ) ^{2}\int _{-L}^{L}e^{-x}\cos \left ( n\frac{\pi }{L}x\right ) dx \end{align*}
But \(\int _{-L}^{L}e^{-x}\cos \left ( n\frac{\pi }{L}x\right ) dx=I\,\) and the above becomes\[ I=-e^{-L}\cos \left ( n\pi \right ) +e^{L}\cos \left ( n\pi \right ) -\left ( \frac{n\pi }{L}\right ) ^{2}I \] Simplifying and solving for \(I\)\begin{align*} I+\left ( \frac{n\pi }{L}\right ) ^{2}I & =\cos \left ( n\pi \right ) \left ( e^{L}-e^{-L}\right ) \\ I\left ( 1+\left ( \frac{n\pi }{L}\right ) ^{2}\right ) & =\cos \left ( n\pi \right ) \left ( e^{L}-e^{-L}\right ) \\ I\left ( \frac{L^{2}+n^{2}\pi ^{2}}{L^{2}}\right ) & =\cos \left ( n\pi \right ) \left ( e^{L}-e^{-L}\right ) \\ I & =\left ( \frac{L^{2}}{L^{2}+n^{2}\pi ^{2}}\right ) \cos \left ( n\pi \right ) \left ( e^{L}-e^{-L}\right ) \end{align*}
Hence \(a_{n}\) becomes\[ a_{n}=\frac{1}{L}\left ( \frac{L^{2}}{L^{2}+n^{2}\pi ^{2}}\right ) \cos \left ( n\pi \right ) \left ( e^{L}-e^{-L}\right ) \] But \(\cos \left ( n\pi \right ) =-1^{n}\) hence\[ a_{n}=\left ( -1\right ) ^{n}\left ( \frac{L}{n^{2}\pi ^{2}+L^{2}}\right ) \left ( e^{L}-e^{-L}\right ) \] Similarly for \(b_{n}\)\[ b_{n}=\frac{1}{L}\int _{-L}^{L}e^{-x}\sin \left ( n\frac{\pi }{L}x\right ) dx \] This can be done using integration by parts. \(\int udv=uv-\int vdu\). Let \[ I=\int _{-L}^{L}e^{-x}\sin \left ( n\frac{\pi }{L}x\right ) dx \] and \(u=\sin \left ( n\frac{\pi }{L}x\right ) ,dv=e^{-x},\rightarrow du=\frac{n\pi }{L}\cos \left ( n\frac{\pi }{L}x\right ) ,v=-e^{-x}\), therefore\begin{align*} I & =\left [ uv\right ] _{-L}^{L}-\int _{-L}^{L}vdu\\ & =\overset{0}{\overbrace{\left [ -e^{-x}\sin \left ( n\frac{\pi }{L}x\right ) \right ] _{-L}^{L}}}+\frac{n\pi }{L}\int _{-L}^{L}e^{-x}\cos \left ( n\frac{\pi }{L}x\right ) dx\\ & =\frac{n\pi }{L}\int _{-L}^{L}e^{-x}\cos \left ( n\frac{\pi }{L}x\right ) dx \end{align*}
Applying integration by parts again to \(\int e^{-x}\cos \left ( n\frac{\pi }{L}x\right ) dx\) where now \(u=\cos \left ( n\frac{\pi }{L}x\right ) ,dv=e^{-x}\rightarrow du=\frac{-n\pi }{L}\sin \left ( n\frac{\pi }{L}x\right ) ,v=-e^{-x}\), hence the above becomes\begin{align*} I & =\frac{n\pi }{L}\left ( uv-\int vdu\right ) \\ & =\frac{n\pi }{L}\left ( \left [ -e^{-x}\cos \left ( n\frac{\pi }{L}x\right ) \right ] _{-L}^{L}-\frac{n\pi }{L}\int _{-L}^{L}e^{-x}\sin \left ( n\frac{\pi }{L}x\right ) dx\right ) \\ & =\frac{n\pi }{L}\left ( -e^{-L}\cos \left ( n\frac{\pi }{L}L\right ) +e^{L}\cos \left ( n\frac{\pi }{L}L\right ) -\frac{n\pi }{L}\int _{-L}^{L}e^{-x}\sin \left ( n\frac{\pi }{L}x\right ) dx\right ) \\ & =\frac{n\pi }{L}\left ( \cos \left ( n\pi \right ) \left ( e^{L}-e^{-L}\right ) -\frac{n\pi }{L}\int _{-L}^{L}e^{-x}\sin \left ( n\frac{\pi }{L}x\right ) dx\right ) \end{align*}
But \(\int _{-L}^{L}e^{-x}\cos \left ( n\frac{\pi }{L}x\right ) dx=I\,\) and the above becomes\[ I=\frac{n\pi }{L}\left ( \cos \left ( n\pi \right ) \left ( e^{L}-e^{-L}\right ) -\frac{n\pi }{L}I\right ) \] Simplifying and solving for \(I\)\begin{align*} I & =\frac{n\pi }{L}\cos \left ( n\pi \right ) \left ( e^{L}-e^{-L}\right ) -\left ( \frac{n\pi }{L}\right ) ^{2}I\\ I+\left ( \frac{n\pi }{L}\right ) ^{2}I & =\frac{n\pi }{L}\cos \left ( n\pi \right ) \left ( e^{L}-e^{-L}\right ) \\ I\left ( 1+\left ( \frac{n\pi }{L}\right ) ^{2}\right ) & =\frac{n\pi }{L}\cos \left ( n\pi \right ) \left ( e^{L}-e^{-L}\right ) \\ I\left ( \frac{L^{2}+n^{2}\pi ^{2}}{L^{2}}\right ) & =\frac{n\pi }{L}\cos \left ( n\pi \right ) \left ( e^{L}-e^{-L}\right ) \\ I & =\left ( \frac{L^{2}}{L^{2}+n^{2}\pi ^{2}}\right ) \frac{n\pi }{L}\cos \left ( n\pi \right ) \left ( e^{L}-e^{-L}\right ) \end{align*}
Hence \(b_{n}\) becomes\begin{align*} b_{n} & =\frac{1}{L}\left ( \frac{L^{2}}{L^{2}+n^{2}\pi ^{2}}\right ) \frac{n\pi }{L}\cos \left ( n\pi \right ) \left ( e^{L}-e^{-L}\right ) \\ & =\left ( \frac{n\pi }{L^{2}+n^{2}\pi ^{2}}\right ) \cos \left ( n\pi \right ) \left ( e^{L}-e^{-L}\right ) \end{align*}
But \(\cos \left ( n\pi \right ) =-1^{n}\) hence\[ b_{n}=\left ( -1\right ) ^{n}\left ( \frac{n\pi }{L^{2}+n^{2}\pi ^{2}}\right ) \left ( e^{L}-e^{-L}\right ) \] Summary\begin{align*} a_{0} & =\frac{e^{L}-e^{-L}}{2L}\\ a_{n} & =\left ( -1\right ) ^{n}\left ( \frac{L}{n^{2}\pi ^{2}+L^{2}}\right ) \left ( e^{L}-e^{-L}\right ) \\ b_{n} & =\left ( -1\right ) ^{n}\left ( \frac{n\pi }{L^{2}+n^{2}\pi ^{2}}\right ) \left ( e^{L}-e^{-L}\right ) \\ f\left ( x\right ) & \approx a_{0}+\sum _{n=1}^{\infty }a_{n}\cos \left ( n\left ( \frac{2\pi }{T}\right ) x\right ) +b_{n}\sin \left ( n\left ( \frac{2\pi }{T}\right ) x\right ) \\ & \approx a_{0}+\sum _{n=1}^{\infty }a_{n}\cos \left ( n\frac{\pi }{L}x\right ) +b_{n}\sin \left ( n\frac{\pi }{L}x\right ) \end{align*}
The following shows the approximation \(f\left ( x\right ) \) for increasing number of terms. Notice the Gibbs phenomena at the jump discontinuity.
The following is sketch of periodic extension of \(f\left ( x\right ) \) from \(x=-L\cdots L\) (for \(L=1\)) for illustration. The function will converge to \(f\left ( x\right ) \) between \(x=-L\cdots L\) and between \(x=-3L\cdots -L\) and between \(x=L\cdots 3L\) and so on. But at the jump discontinuities which occurs at \(x=\cdots ,-3L,-L,L,3L,\cdots \) it will converge to the average \(\frac{1}{2}\) shown as small circles in the sketch.
By definitions,\begin{align*} a_{0} & =\frac{1}{T}\int _{-T/2}^{T/2}f\left ( x\right ) dx\\ a_{n} & =\frac{1}{T/2}\int _{-T/2}^{T/2}f\left ( x\right ) \cos \left ( n\left ( \frac{2\pi }{T}\right ) x\right ) dx\\ b_{n} & =\frac{1}{T/2}\int _{-T/2}^{T/2}f\left ( x\right ) \sin \left ( n\left ( \frac{2\pi }{T}\right ) x\right ) dx \end{align*}
The period here is \(T=2L\), therefore the above becomes\begin{align*} a_{0} & =\frac{1}{2L}\int _{-L}^{L}f\left ( x\right ) dx\\ a_{n} & =\frac{1}{L}\int _{-L}^{L}f\left ( x\right ) \cos \left ( n\frac{\pi }{L}x\right ) dx\\ b_{n} & =\frac{1}{L}\int _{-L}^{L}f\left ( x\right ) \sin \left ( n\frac{\pi }{L}x\right ) dx \end{align*}
These are now evaluated for given \(f\left ( x\right ) \)\begin{align*} a_{0} & =\frac{1}{2L}\int _{-L}^{L}f\left ( x\right ) dx\\ & =\frac{1}{2L}\left ( \int _{-L}^{0}f\left ( x\right ) dx+\int _{0}^{L}f\left ( x\right ) dx\right ) \\ & =\frac{1}{2L}\left ( 0+\int _{0}^{L}xdx\right ) \\ & =\frac{1}{2L}\left ( \frac{x^{2}}{2}\right ) _{0}^{L}\\ & =\frac{L}{4} \end{align*}
Now \(a_{n}\) is found\begin{align*} a_{n} & =\frac{1}{L}\int _{-L}^{L}f\left ( x\right ) \cos \left ( n\frac{\pi }{L}x\right ) dx\\ & =\frac{1}{L}\left ( \int _{-L}^{0}f\left ( x\right ) \cos \left ( n\frac{\pi }{L}x\right ) dx+\int _{0}^{L}f\left ( x\right ) \cos \left ( n\frac{\pi }{L}x\right ) dx\right ) \\ & =\frac{1}{L}\int _{0}^{L}x\cos \left ( n\frac{\pi }{L}x\right ) dx \end{align*}
Integration by parts. Let \(u=x,du=1,dv=\cos \left ( n\frac{\pi }{L}x\right ) ,v=\frac{\sin \left ( n\frac{\pi }{L}x\right ) }{n\frac{\pi }{L}}\), hence the above becomes\begin{align*} a_{n} & =\frac{1}{L}\left ( \overset{0}{\overbrace{\left ( \frac{n\pi }{L}x\sin \left ( n\frac{\pi }{L}x\right ) \right ) _{0}^{L}}}-\int _{0}^{L}\frac{\sin \left ( n\frac{\pi }{L}x\right ) }{n\frac{\pi }{L}}dx\right ) \\ & =\frac{1}{L}\left ( -\frac{L}{n\pi }\int _{0}^{L}\sin \left ( n\frac{\pi }{L}x\right ) dx\right ) \\ & =\frac{1}{L}\left ( -\frac{L}{n\pi }\left ( \frac{-\cos \left ( n\frac{\pi }{L}x\right ) }{n\frac{\pi }{L}}\right ) _{0}^{L}\right ) \\ & =\frac{1}{L}\left ( \left ( \frac{L}{n\pi }\right ) ^{2}\cos \left ( n\frac{\pi }{L}x\right ) _{0}^{L}\right ) \\ & =\frac{L}{n^{2}\pi ^{2}}\cos \left ( n\frac{\pi }{L}x\right ) _{0}^{L}\\ & =\frac{L}{n^{2}\pi ^{2}}\left [ \cos \left ( n\frac{\pi }{L}L\right ) -1\right ] \\ & =\frac{L}{n^{2}\pi ^{2}}\left [ -1^{n}-1\right ] \end{align*}
Now \(b_{n}\) is found\begin{align*} b_{n} & =\frac{1}{L}\int _{-L}^{L}f\left ( x\right ) \sin \left ( n\frac{\pi }{L}x\right ) dx\\ & =\frac{1}{L}\left ( \int _{-L}^{0}f\left ( x\right ) \sin \left ( n\frac{\pi }{L}x\right ) dx+\int _{0}^{L}f\left ( x\right ) \sin \left ( n\frac{\pi }{L}x\right ) dx\right ) \\ & =\frac{1}{L}\int _{0}^{L}x\sin \left ( n\frac{\pi }{L}x\right ) dx \end{align*}
Integration by parts. Let \(u=x,du=1,dv=\sin \left ( n\frac{\pi }{L}x\right ) ,v=\frac{-\cos \left ( n\frac{\pi }{L}x\right ) }{n\frac{\pi }{L}}\), hence the above becomes\begin{align*} b_{n} & =\frac{1}{L}\left ( \left ( -\frac{L}{n\pi }x\cos \left ( n\frac{\pi }{L}x\right ) \right ) _{0}^{L}+\int _{0}^{L}\frac{\cos \left ( n\frac{\pi }{L}x\right ) }{n\frac{\pi }{L}}dx\right ) \\ & =\frac{1}{L}\left ( -\frac{L}{n\pi }\left ( L\cos \left ( n\frac{\pi }{L}L\right ) -0\right ) +\frac{L}{n\pi }\int _{0}^{L}\cos \left ( n\frac{\pi }{L}x\right ) dx\right ) \\ & =\frac{1}{L}\left ( -\frac{L^{2}}{n\pi }\left ( -1\right ) ^{n}+\frac{L}{n\pi }\overset{0}{\overbrace{\left [ \frac{\sin \left ( n\frac{\pi }{L}x\right ) }{n\frac{\pi }{L}}\right ] _{0}^{L}}}\right ) \\ & =\frac{L}{n\pi }\left ( -\left ( -1\right ) ^{n}\right ) \\ & =\left ( -1\right ) ^{n+1}\frac{L}{n\pi } \end{align*}
Summary\begin{align*} a_{0} & =\frac{L}{4}\\ a_{n} & =\frac{L}{n^{2}\pi ^{2}}\left [ -1^{n}-1\right ] \\ b_{n} & =\left ( -1\right ) ^{n+1}\frac{L}{n\pi }\\ f\left ( x\right ) & \approx a_{0}+\sum _{n=1}^{\infty }a_{n}\cos \left ( n\left ( \frac{2\pi }{T}\right ) x\right ) +b_{n}\sin \left ( n\left ( \frac{2\pi }{T}\right ) x\right ) \\ & \approx a_{0}+\sum _{n=1}^{\infty }a_{n}\cos \left ( n\frac{\pi }{L}x\right ) +b_{n}\sin \left ( n\frac{\pi }{L}x\right ) \end{align*}
The following shows the approximation \(f\left ( x\right ) \) for increasing number of terms. Notice the Gibbs phenomena at the jump discontinuity.
It will converge to the average value of the function at the end points after making periodic extensions of the function. Specifically, at \(x=-L\) the Fourier series will converge to \[ \frac{1}{2}\left ( f\left ( -L\right ) +f\left ( L\right ) \right ) \] And at \(x=L\) it will converge to \[ \frac{1}{2}\left ( f\left ( L\right ) +f\left ( -L\right ) \right ) \] Notice that if \(f\left ( L\right ) \) has same value as \(f\left ( -L\right ) \), then there will not be a jump discontinuity when periodic extension are made, and the above formula simply gives the value of the function at either end, since it is the same value.
\[ f\left ( x\right ) =\left \{ \begin{array} [c]{ccc}1 & & x<\frac{L}{2}\\ 0 & & x>\frac{L}{2}\end{array} \right . \] The first step is to sketch \(f\left ( x\right ) \) over \(0\cdots L\). This is the result for \(L=1\) as an example.
The second step is to make an odd extension of \(f\left ( x\right ) \) over \(-L\cdots L\). This is the result.
The third step is to extend the above as periodic function with period \(2L\) (as normally would be done) and mark the average value at the jump discontinuities. This is the result
Now the Fourier sin series is found for the above function. Since the function \(f\left ( x\right ) \) is odd, then only \(b_{n}\) will exist\begin{align*} f\left ( x\right ) & \approx \sum _{n=1}^{\infty }b_{n}\sin \left ( n\left ( \frac{2\pi }{2L}\right ) x\right ) \\ & \approx \sum _{n=1}^{\infty }b_{n}\sin \left ( n\frac{\pi }{L}x\right ) \end{align*}
Where\[ b_{n}=\frac{1}{L}\int _{-L}^{L}f\left ( x\right ) \sin \left ( n\left ( \frac{2\pi }{2L}\right ) x\right ) dx=\frac{1}{L}\int _{-L}^{L}f\left ( x\right ) \sin \left ( n\frac{\pi }{L}x\right ) dx \] Since \(f\left ( x\right ) \sin \left ( n\frac{\pi }{L}x\right ) \) is even, then the above becomes\begin{align*} b_{n} & =\frac{2}{L}\int _{0}^{L}f\left ( x\right ) \sin \left ( n\frac{\pi }{L}x\right ) dx\\ & =\frac{2}{L}\left ( \int _{0}^{L/2}1\times \sin \left ( n\frac{\pi }{L}x\right ) dx+\int _{0}^{L/2}0\times \sin \left ( n\frac{\pi }{L}x\right ) dx\right ) \\ & =\frac{2}{L}\int _{0}^{L/2}\sin \left ( n\frac{\pi }{L}x\right ) dx\\ & =\frac{2}{L}\left [ -\frac{\cos \left ( n\frac{\pi }{L}x\right ) }{n\frac{\pi }{L}}\right ] _{0}^{L/2}\\ & =\frac{-2}{n\pi }\left [ \cos \left ( n\frac{\pi }{L}x\right ) \right ] _{0}^{L/2}\\ & =\frac{-2}{n\pi }\left [ \cos \left ( n\frac{\pi }{L}\frac{L}{2}\right ) -1\right ] \\ & =\frac{-2}{n\pi }\left [ \cos \left ( \frac{n\pi }{2}\right ) -1\right ] \\ & =\frac{2}{n\pi }\left [ 1-\cos \left ( \frac{n\pi }{2}\right ) \right ] \end{align*}
Therefore\[ f\left ( x\right ) \approx \sum _{n=1}^{\infty }\frac{2}{n\pi }\left ( 1-\cos \left ( \frac{n\pi }{2}\right ) \right ) \sin \left ( n\frac{\pi }{L}x\right ) \] The following shows the approximation \(f\left ( x\right ) \) for increasing number of terms. Notice the Gibbs phenomena at the jump discontinuity.
This is the same problem as 3.3.2 part (d). But it asks to plot for \(n=1\) and \(n=2\) in the sum. The sketch of the Fourier sin series was done above in solving 3.3.2 part(d) and will not be repeated again. From above, it was found that\[ f\left ( x\right ) \approx \sum _{n=1}^{\infty }B_{n}\sin \left ( n\frac{\pi }{L}x\right ) \] Where \(B_{n}=\frac{2}{n\pi }\left [ 1-\cos \left ( \frac{n\pi }{2}\right ) \right ] \). The following is the plot for \(n=1\cdots 10\).
The even extension of \(f\left ( x\right ) \) is \[ \left \{ \begin{array} [c]{ccc}f\left ( x\right ) & & x>0\\ f\left ( -x\right ) & & x<0 \end{array} \right . \] But the even part of \(f\left ( x\right ) \) is \[ \frac{1}{2}\left ( f\left ( x\right ) +f\left ( -x\right ) \right ) \]
The odd extension of \(f\left ( x\right ) \) is \[ \left \{ \begin{array} [c]{ccc}f\left ( x\right ) & & x>0\\ -f\left ( -x\right ) & & x<0 \end{array} \right . \] While the odd part of \(f\left ( x\right ) \) is \[ \frac{1}{2}\left ( f\left ( x\right ) -f\left ( -x\right ) \right ) \]
First a plot of \(f\left ( x\right ) \) is given
\[ f\left ( x\right ) =\left \{ \begin{array} [c]{ccc}x & & x>0\\ x^{2} & & x<0 \end{array} \right . \]
A plot of even extension and the even part for \(f\left ( x\right ) \) Is given below
A plot of odd extension and the odd part is given below
Adding the even part and the odd part gives back the original function
Plot of adding the even extension and the odd extension is below
Fourier sin series of \(f^{\prime }\left ( x\right ) \) is given by, assuming period is \(-L\cdots L\)\[ f^{\prime }\left ( x\right ) \sim \sum _{n=1}^{\infty }b_{n}\sin \left ( n\frac{\pi }{L}x\right ) \] Where\[ b_{n}=\frac{2}{L}\int _{0}^{L}f^{\prime }\left ( x\right ) \sin \left ( n\frac{\pi }{L}x\right ) dx \] Applying integration by parts. Let \(f^{\prime }\left ( x\right ) =dv,u=\sin \left ( n\frac{\pi }{L}x\right ) \), then \(v=f\left ( x\right ) ,du=\frac{n\pi }{L}\cos \left ( \frac{n\pi }{L}x\right ) \). Since \(v=f\left ( x\right ) \) has has jump discontinuity at \(x_{0}\) as described, and assuming \(x_{0}>0\), then, and using \(\sin \left ( n\frac{\pi }{L}x\right ) =0\) at \(x=L\) \begin{align} b_{n} & =\frac{2}{L}\int _{0}^{L}udv\nonumber \\ & =\frac{2}{L}\left [ \left ( \left [ uv\right ] _{0}^{x_{0}^{-}}+\left [ uv\right ] _{x_{0}^{+}}^{L}\right ) -\int _{0}^{L}vdu\right ] \nonumber \\ & =\frac{2}{L}\left ( \left [ \sin \left ( n\frac{\pi }{L}x\right ) f\left ( x\right ) \right ] _{0}^{x_{0}^{-}}+\left [ \sin \left ( n\frac{\pi }{L}x\right ) f\left ( x\right ) \right ] _{x_{0}^{+}}^{L}-\frac{n\pi }{L}\int _{0}^{L}f\left ( x\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx\right ) \nonumber \\ & =\frac{2}{L}\left ( \sin \left ( n\frac{\pi }{L}x_{0}^{-}\right ) f\left ( x_{0}^{-}\right ) -\sin \left ( n\frac{\pi }{L}x_{0}^{+}f\left ( x_{0}^{+}\right ) \right ) -\frac{n\pi }{L}\int _{0}^{L}f\left ( x\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx\right ) \tag{1} \end{align}
In the above, \(\sin \left ( n\frac{\pi }{L}x\right ) =0\) and at \(x=L\) was used. But\begin{align*} f\left ( x_{0}^{-}\right ) & =\alpha \\ f\left ( x_{0}^{+}\right ) & =\beta \end{align*}
And since \(\sin \) is continuous, then \(\sin \left ( n\frac{\pi }{L}x_{0}^{-}\right ) =\sin \left ( n\frac{\pi }{L}x_{0}^{+}\right ) =\sin \left ( n\frac{\pi }{L}x_{0}\right ) \). Equation (1) simplifies to\begin{equation} b_{n}=\frac{2}{L}\left ( \left ( \alpha -\beta \right ) \sin \left ( n\frac{\pi }{L}x_{0}\right ) -\frac{n\pi }{L}\int _{0}^{L}f\left ( x\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx\right ) \tag{2} \end{equation} On the other hand, the Fourier cosine series for \(f\left ( x\right ) \) is given by\[ f\left ( x\right ) \sim a_{0}+\sum _{n=1}^{\infty }a_{n}\cos \left ( n\frac{\pi }{L}x\right ) \] Where\begin{align*} a_{0} & =\frac{1}{L}\int _{0}^{L}f\left ( x\right ) dx\\ a_{n} & =\frac{2}{L}\int _{0}^{L}f\left ( x\right ) \cos \left ( n\frac{\pi }{L}x\right ) dx \end{align*}
Therefore \(\int _{0}^{L}f\left ( x\right ) \cos \left ( n\frac{\pi }{L}x\right ) dx=\frac{L}{2}a_{n}\). Substituting this into (2) gives\begin{align*} b_{n} & =\frac{2}{L}\left ( \left ( \alpha -\beta \right ) \sin \left ( n\frac{\pi }{L}x_{0}\right ) -\frac{n\pi }{L}\left ( \frac{L}{2}a_{n}\right ) \right ) \\ & =\frac{2}{L}\left ( \alpha -\beta \right ) \sin \left ( n\frac{\pi }{L}x_{0}\right ) -\frac{2}{L}\frac{n\pi }{L}\left ( \frac{L}{2}a_{n}\right ) \end{align*}
Hence\begin{equation} \fbox{$b_n=\frac{2}{L}\sin \left ( n\frac{\pi }{L}x_0\right ) \left ( \alpha -\beta \right ) -\frac{n\pi }{L}a_n$} \tag{3} \end{equation} Summary the Fourier \(\sin \) series of \(f^{\prime }\left ( x\right ) \) is\[ f^{\prime }\left ( x\right ) \sim \sum _{n=1}^{\infty }b_{n}\sin \left ( n\frac{\pi }{L}x\right ) \] With \(b_{n}\) given by (3). The above is in terms of \(a_{n}\), which is the Fourier cosine series of \(f\left ( x\right ) \), which is what required to show. In addition, the \(\cos \) series of \(f\left ( x\right ) \) can also be written in terms of \(\sin \) series of \(f^{\prime }\left ( x\right ) \). From (3), solving for \(a_{n}\)\begin{align*} a_{n} & =\frac{L}{n\pi }b_{n}-\frac{2}{n\pi }\sin \left ( n\frac{\pi }{L}x_{0}\right ) \left ( \alpha -\beta \right ) \\ f\left ( x\right ) & \sim a_{0}+\sum _{n=1}^{\infty }\frac{1}{n}\left ( \frac{L}{\pi }b_{n}-\frac{2}{\pi }\sin \left ( n\frac{\pi }{L}x_{0}\right ) \left ( \alpha -\beta \right ) \right ) \cos \left ( \frac{n\pi }{L}x\right ) \end{align*}
This shows more clearly that the Fourier series of \(f\left ( x\right ) \) has order of convergence in \(a_{n}\) as \(\frac{1}{n}\) as expected.
Fourier \(\cos \) series of \(f^{\prime }\left ( x\right ) \) is given by, assuming period is \(-L\cdots L\)\[ f^{\prime }\left ( x\right ) \sim \sum _{n=0}^{\infty }a_{n}\cos \left ( n\frac{\pi }{L}x\right ) \] Where\begin{align*} a_{0} & =\frac{1}{L}\int _{0}^{L}f^{\prime }\left ( x\right ) dx\\ & =\frac{1}{L}\left ( \int _{0}^{x_{0}^{-}}f^{\prime }\left ( x\right ) dx+\int _{x_{0}^{+}}^{L}f^{\prime }\left ( x\right ) dx\right ) \\ & =\frac{1}{L}\left ( \left [ f\left ( x\right ) \right ] _{0}^{x_{0}^{-}}+\left [ f\left ( x\right ) \right ] _{x_{0}^{+}}^{L}\right ) \\ & =\frac{1}{L}\left ( \left [ \alpha -f\left ( 0\right ) \right ] +\left [ f\left ( L\right ) -\beta \right ] \right ) \\ & =\frac{\left ( \alpha -\beta \right ) }{L}+\frac{f\left ( 0\right ) +f\left ( L\right ) }{L} \end{align*}
And for \(n>0\)\[ a_{n}=\frac{2}{L}\int _{0}^{L}f^{\prime }\left ( x\right ) \cos \left ( n\frac{\pi }{L}x\right ) dx \] Applying integration by parts. Let \(f^{\prime }\left ( x\right ) =dv,u=\cos \left ( n\frac{\pi }{L}x\right ) \), then \(v=f\left ( x\right ) ,du=\frac{-n\pi }{L}\sin \left ( \frac{n\pi }{L}x\right ) \). Since \(v=f\left ( x\right ) \) has has jump discontinuity at \(x_{0}\) as described, then \begin{align} a_{n} & =\frac{2}{L}\int _{0}^{L}udv\nonumber \\ & =\frac{2}{L}\left [ \left ( \left [ uv\right ] _{0}^{x_{0}^{-}}+\left [ uv\right ] _{x_{0}^{+}}^{L}\right ) -\int _{0}^{L}vdu\right ] \nonumber \\ & =\frac{2}{L}\left ( \left [ \cos \left ( n\frac{\pi }{L}x\right ) f\left ( x\right ) \right ] _{0}^{x_{0}^{-}}+\left [ \cos \left ( n\frac{\pi }{L}x\right ) f\left ( x\right ) \right ] _{x_{0}^{+}}^{L}+\frac{n\pi }{L}\int _{0}^{L}f\left ( x\right ) \sin \left ( \frac{n\pi }{L}x\right ) dx\right ) \nonumber \\ & =\frac{2}{L}\left ( \cos \left ( n\frac{\pi }{L}x_{0}^{-}\right ) f\left ( x_{0}^{-}\right ) -f\left ( 0\right ) +\cos \left ( n\pi \right ) f\left ( L\right ) -\cos \left ( n\frac{\pi }{L}x_{0}^{+}\right ) f\left ( x_{0}^{+}\right ) +\frac{n\pi }{L}\int _{0}^{L}f\left ( x\right ) \sin \left ( \frac{n\pi }{L}x\right ) dx\right ) \tag{1} \end{align}
But\begin{align*} f\left ( x_{0}^{-}\right ) & =\alpha \\ f\left ( x_{0}^{+}\right ) & =\beta \end{align*}
And since \(\cos \) is continuous, then \(\cos \left ( n\frac{\pi }{L}x_{0}^{-}\right ) =\cos \left ( n\frac{\pi }{L}x_{0}^{+}\right ) =\cos \left ( n\frac{\pi }{L}x_{0}\right ) \), therefore (1) becomes\begin{equation} a_{n}=\frac{2}{L}\left ( \cos \left ( n\pi \right ) f\left ( L\right ) -f\left ( 0\right ) +\cos \left ( n\frac{\pi }{L}x_{0}\right ) \left ( \alpha -\beta \right ) +\frac{n\pi }{L}\int _{0}^{L}f\left ( x\right ) \sin \left ( \frac{n\pi }{L}x\right ) dx\right ) \tag{2} \end{equation} On the other hand, the Fourier \(sin\) series for \(f\left ( x\right ) \) is given by\[ f\left ( x\right ) \sim \sum _{n=0}^{\infty }b_{n}\sin \left ( n\frac{\pi }{L}x\right ) \] Where\[ b_{n}=\frac{2}{L}\int _{0}^{L}f\left ( x\right ) \sin \left ( n\frac{\pi }{L}x\right ) dx \] Therefore \(\int _{0}^{L}f\left ( x\right ) \sin \left ( n\frac{\pi }{L}x\right ) dx=\frac{L}{2}b_{n}\). Substituting this into (2) gives\begin{align*} a_{n} & =\frac{2}{L}\left ( \cos \left ( n\pi \right ) f\left ( L\right ) -f\left ( 0\right ) +\cos \left ( n\frac{\pi }{L}x_{0}\right ) \left ( \alpha -\beta \right ) +\frac{n\pi }{L}\frac{L}{2}b_{n}\right ) \\ & =\frac{2}{L}\cos \left ( n\pi \right ) f\left ( L\right ) -\frac{2}{L}f\left ( 0\right ) +\frac{2}{L}\cos \left ( n\frac{\pi }{L}x_{0}\right ) \left ( \alpha -\beta \right ) +\frac{2}{L}\frac{n\pi }{2}b_{n}\\ & =\frac{2}{L}\left ( \left ( -1^{n}\right ) f\left ( L\right ) -f\left ( 0\right ) \right ) +\frac{2}{L}\cos \left ( n\frac{\pi }{L}x_{0}\right ) \left ( \alpha -\beta \right ) +\frac{n\pi }{L}b_{n} \end{align*}
Hence\begin{equation} \fbox{$a_n=\frac{2}{L}\left ( \left ( -1^n\right ) f\left ( L\right ) -f\left ( 0\right ) \right ) +\frac{2}{L}\cos \left ( n\frac{\pi }{L}x_0\right ) \left ( \alpha -\beta \right ) +\frac{n\pi }{L}b_n$} \tag{3} \end{equation} Summary the Fourier \(\cos \) series of \(f^{\prime }\left ( x\right ) \) is\begin{align*} f^{\prime }\left ( x\right ) & \sim \sum _{n=0}^{\infty }a_{n}\cos \left ( n\frac{\pi }{L}x\right ) \\ a_{0} & =\frac{\left ( \alpha -\beta \right ) }{L}+\frac{f\left ( 0\right ) +f\left ( L\right ) }{L}\\ a_{n} & =\frac{2}{L}\left ( \left ( -1^{n}\right ) f\left ( L\right ) -f\left ( 0\right ) \right ) +\frac{2}{L}\cos \left ( n\frac{\pi }{L}x_{0}\right ) \left ( \alpha -\beta \right ) +\frac{n\pi }{L}b_{n} \end{align*}
The above is in terms of \(b_{n}\), which is the Fourier \(sin\) series of \(f\left ( x\right ) \), which is what required to show.
The PDE is\begin{equation} \frac{\partial u}{\partial t}=k\frac{\partial ^{2}u}{\partial x^{2}}+q\left ( x,t\right ) \tag{1} \end{equation} Since the boundary conditions are homogenous Dirichlet conditions, then the solution can be written down as\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }b_{n}\left ( t\right ) \sin \left ( n\frac{\pi }{L}x\right ) \] Since the solution is assumed to be continuous with continuous derivative, then term by term differentiation is allowed w.r.t. \(x\)\begin{align} \frac{\partial u}{\partial x} & =\sum _{n=1}^{\infty }n\frac{\pi }{L}b_{n}\left ( t\right ) \cos \left ( n\frac{\pi }{L}x\right ) \nonumber \\ \frac{\partial ^{2}u}{\partial x^{2}} & =-\sum _{n=1}^{\infty }\left ( \frac{n\pi }{L}\right ) ^{2}b_{n}\left ( t\right ) \sin \left ( n\frac{\pi }{L}x\right ) \tag{2} \end{align}
Also using assumption that \(\frac{\partial u}{\partial t}\) is smooth, then\begin{equation} \frac{\partial u}{\partial t}=\sum _{n=1}^{\infty }\frac{db_{n}\left ( t\right ) }{dt}\sin \left ( n\frac{\pi }{L}x\right ) \tag{3} \end{equation} Substituting (2,3) into (1) gives\begin{equation} \sum _{n=1}^{\infty }\frac{db_{n}\left ( t\right ) }{dt}\sin \left ( n\frac{\pi }{L}x\right ) =-k\sum _{n=1}^{\infty }\left ( \frac{n\pi }{L}\right ) ^{2}b_{n}\left ( t\right ) \sin \left ( n\frac{\pi }{L}x\right ) +q\left ( x,t\right ) \tag{4} \end{equation} Expanding \(q\left ( x,t\right ) \) as Fourier \(\sin \) series in \(x\). Hence\[ q\left ( x,t\right ) =\sum _{n=1}^{\infty }q_{n}\left ( t\right ) \sin \left ( \frac{n\pi }{L}x\right ) \] Where now \(q_{n}\left ( t\right ) \) are time dependent given by (by orthogonality)\[ q_{n}\left ( t\right ) =\frac{2}{L}\int _{0}^{L}q\left ( x,t\right ) \sin \left ( \frac{n\pi }{L}x\right ) \] Hence (4) becomes\[ \sum _{n=1}^{\infty }\frac{db_{n}\left ( t\right ) }{dt}\sin \left ( n\frac{\pi }{L}x\right ) =-\sum _{n=1}^{\infty }k\left ( \frac{n\pi }{L}\right ) ^{2}b_{n}\left ( t\right ) \sin \left ( n\frac{\pi }{L}x\right ) +\sum _{n=1}^{\infty }q\left ( t\right ) _{n}\sin \left ( \frac{n\pi }{L}x\right ) \] Applying orthogonality the above reduces to one term only\[ \frac{db_{n}\left ( t\right ) }{dt}\sin \left ( n\frac{\pi }{L}x\right ) =-k\left ( \frac{n\pi }{L}\right ) ^{2}b_{n}\left ( t\right ) \sin \left ( n\frac{\pi }{L}x\right ) +q\left ( t\right ) _{n}\sin \left ( \frac{n\pi }{L}x\right ) \] Dividing by \(\sin \left ( n\frac{\pi }{L}x\right ) \neq 0\)\begin{align} \frac{db_{n}\left ( t\right ) }{dt} & =-k\left ( \frac{n\pi }{L}\right ) ^{2}b_{n}\left ( t\right ) +q_{n}\left ( t\right ) \nonumber \\ \frac{db_{n}\left ( t\right ) }{dt}+k\left ( \frac{n\pi }{L}\right ) ^{2}B_{n}\left ( t\right ) & =q_{n}\left ( t\right ) \tag{5} \end{align}
The above is the ODE that needs to be solved for \(b_{n}\left ( t\right ) \). It is first order inhomogeneous ODE. The question asks to stop here.
The PDE is\begin{equation} \frac{\partial u}{\partial t}=k\frac{\partial ^{2}u}{\partial x^{2}}+g\left ( x\right ) \tag{1} \end{equation} Since the boundary conditions are homogenous Dirichlet conditions, then the solution can be written down as\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }b_{n}\left ( t\right ) \sin \left ( n\frac{\pi }{L}x\right ) \] Since the solution is assumed to be continuous with continuous derivative, then term by term differentiation is allowed w.r.t. \(x\)\begin{align} \frac{\partial u}{\partial x} & =\sum _{n=1}^{\infty }n\frac{\pi }{L}b_{n}\left ( t\right ) \cos \left ( n\frac{\pi }{L}x\right ) \nonumber \\ \frac{\partial ^{2}u}{\partial x^{2}} & =-\sum _{n=1}^{\infty }\left ( \frac{n\pi }{L}\right ) ^{2}b_{n}\left ( t\right ) \sin \left ( n\frac{\pi }{L}x\right ) \tag{2} \end{align}
Also using assumption that \(\frac{\partial u}{\partial t}\) is smooth, then\begin{equation} \frac{\partial u}{\partial t}=\sum _{n=1}^{\infty }\frac{db_{n}\left ( t\right ) }{dt}\sin \left ( n\frac{\pi }{L}x\right ) \tag{3} \end{equation} Substituting (2,3) into (1) gives\begin{equation} \sum _{n=1}^{\infty }\frac{db_{n}\left ( t\right ) }{dt}\sin \left ( n\frac{\pi }{L}x\right ) =-k\sum _{n=1}^{\infty }\left ( \frac{n\pi }{L}\right ) ^{2}b_{n}\left ( t\right ) \sin \left ( n\frac{\pi }{L}x\right ) +g\left ( x\right ) \tag{4} \end{equation} Using hint given in the problem, which is to expand \(g\left ( x\right ) \) as Fourier \(\sin \) series. Hence\[ g\left ( x\right ) =\sum _{n=1}^{\infty }g_{n}\sin \left ( \frac{n\pi }{L}x\right ) \] Where\[ g_{n}=\frac{2}{L}\int _{0}^{L}g\left ( x\right ) \sin \left ( \frac{n\pi }{L}x\right ) \] Hence (4) becomes\[ \sum _{n=1}^{\infty }\frac{db_{n}\left ( t\right ) }{dt}\sin \left ( n\frac{\pi }{L}x\right ) =-\sum _{n=1}^{\infty }k\left ( \frac{n\pi }{L}\right ) ^{2}b_{n}\left ( t\right ) \sin \left ( n\frac{\pi }{L}x\right ) +\sum _{n=1}^{\infty }g_{n}\sin \left ( \frac{n\pi }{L}x\right ) \] Applying orthogonality the above reduces to one term only\[ \frac{db_{n}\left ( t\right ) }{dt}\sin \left ( n\frac{\pi }{L}x\right ) =-k\left ( \frac{n\pi }{L}\right ) ^{2}b_{n}\left ( t\right ) \sin \left ( n\frac{\pi }{L}x\right ) +g_{n}\sin \left ( \frac{n\pi }{L}x\right ) \] Dividing by \(\sin \left ( n\frac{\pi }{L}x\right ) \neq 0\)\begin{align} \frac{db_{n}\left ( t\right ) }{dt} & =-k\left ( \frac{n\pi }{L}\right ) ^{2}b_{n}\left ( t\right ) +g_{n}\nonumber \\ \frac{db_{n}\left ( t\right ) }{dt}+k\left ( \frac{n\pi }{L}\right ) ^{2}b_{n}\left ( t\right ) & =g_{n} \tag{5} \end{align}
This is of the form \(y^{\prime }+ay=g_{n}\), where \(a=k\left ( \frac{n\pi }{L}\right ) ^{2}\). This is solved using an integration factor \(\mu =e^{at}\), where \(\frac{d}{dt}\left ( e^{at}y\right ) =e^{at}g_{n}\), giving the solution\[ y\left ( t\right ) =\frac{1}{\mu }\int \mu g_{n}dt+\frac{c}{\mu }\] Hence the solution to (5) is\begin{align*} b_{n}\left ( t\right ) e^{k\left ( \frac{n\pi }{L}\right ) ^{2}t} & =\int e^{k\left ( \frac{n\pi }{L}\right ) ^{2}t}g_{n}dt+c\\ b_{n}\left ( t\right ) e^{k\left ( \frac{n\pi }{L}\right ) ^{2}t} & =\frac{L^{2}e^{k\left ( \frac{n\pi }{L}\right ) ^{2}t}}{kn^{2}\pi ^{2}}g_{n}+c\\ b_{n}\left ( t\right ) & =\frac{L^{2}}{kn^{2}\pi ^{2}}g_{n}+ce^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t} \end{align*}
Where \(c\) above is constant of integration. Hence the solution becomes\begin{align*} u\left ( x,t\right ) & =\sum _{n=1}^{\infty }b_{n}\left ( t\right ) \sin \left ( n\frac{\pi }{L}x\right ) \\ & =\sum _{n=1}^{\infty }\left ( \frac{L^{2}}{kn^{2}\pi ^{2}}g_{n}+ce^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t}\right ) \sin \left ( n\frac{\pi }{L}x\right ) \end{align*}
At \(t=0\), \(u\left ( x,0\right ) =f\left ( x\right ) \), therefore\[ f\left ( x\right ) =\sum _{n=1}^{\infty }\left ( \frac{L^{2}}{kn^{2}\pi ^{2}}g_{n}+c\right ) \sin \left ( n\frac{\pi }{L}x\right ) \] Therefore\[ \frac{L^{2}}{kn^{2}\pi ^{2}}g_{n}+c=\frac{2}{L}\int _{0}^{L}f\left ( x\right ) \sin \left ( n\frac{\pi }{L}x\right ) dx \] Solving for \(c\) gives\[ c=\frac{2}{L}\int _{0}^{L}f\left ( x\right ) \sin \left ( n\frac{\pi }{L}x\right ) dx-\frac{L^{2}}{kn^{2}\pi ^{2}}g_{n}\] This completes the solution. Everything is now known. Summary
\begin{align*} u\left ( x,t\right ) & =\sum _{n=1}^{\infty }b_{n}\left ( t\right ) \sin \left ( n\frac{\pi }{L}x\right ) \\ b_{n}\left ( t\right ) & =\left ( \frac{L^{2}}{kn^{2}\pi ^{2}}g_{n}+ce^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t}\right ) \\ g_{n} & =\frac{2}{L}\int _{0}^{L}g\left ( x\right ) \sin \left ( \frac{n\pi }{L}x\right ) \\ c & =\frac{2}{L}\int _{0}^{L}f\left ( x\right ) \sin \left ( n\frac{\pi }{L}x\right ) dx-\frac{L^{2}}{kn^{2}\pi ^{2}}g_{n} \end{align*}