Expand the following functions, which are periodic in \frac{2\pi }{L}, in Fourier series (i) f\left ( x\right ) =1-\frac{\left \vert x\right \vert }{L} for \frac{-L}{2}\leq x\leq \frac{L}{2}. (ii) f\left ( x\right ) =e^{x} for \frac{-L}{2}\leq x\leq \frac{L}{2}
Solution
The following is a plot of the function f\left ( x\right ) =1-\frac{\left \vert x\right \vert }{L}. In the plot below L=1 was used for illustration.
The Fourier series of f\left ( x\right ) = is given by\begin{equation} f\left ( x\right ) =\frac{a_{0}}{2}+\sum _{n=1}^{\infty }a_{n}\cos \left ( \frac{2\pi }{L}nx\right ) +b_{n}\sin \left ( \frac{2\pi }{L}nx\right ) \tag{1} \end{equation}
And a_{n}=\frac{2}{L}\int _{-\frac{L}{2}}^{\frac{L}{2}}f\left ( x\right ) \cos \left ( \frac{2\pi }{L}nx\right ) dx
Using integration by parts: Let u=x,dv=\cos \left ( \frac{2\pi }{L}nx\right ) then du=1,v=\frac{\sin \left ( \frac{2\pi }{L}nx\right ) }{\frac{2\pi }{L}n}=\frac{L}{2\pi n}\sin \left ( \frac{2\pi }{L}nx\right ) . The above integral becomes\begin{align*} \int _{0}^{\frac{L}{2}}x\cos \left ( \frac{2\pi }{L}nx\right ) dx & =\left ( \frac{L}{2\pi n}x\sin \left ( \frac{2\pi }{L}nx\right ) \right ) _{0}^{\frac{L}{2}}-\frac{L}{2\pi n}\int _{0}^{\frac{L}{2}}\sin \left ( \frac{2\pi }{L}nx\right ) dx\\ & =\left ( \frac{L}{2\pi n}\left ( \frac{L}{2}\right ) \sin \left ( \frac{2\pi }{L}n\frac{L}{2}\right ) -0\right ) -\frac{L}{2\pi n}\left ( -\frac{\cos \left ( \frac{2\pi }{L}nx\right ) }{\frac{2\pi }{L}n}\right ) _{0}^{\frac{L}{2}}\\ & =\frac{L^{2}}{4\pi n}\sin \left ( n\pi \right ) +\frac{L^{2}}{4\pi ^{2}n^{2}}\left ( \cos \left ( \frac{2\pi }{L}n\left ( \frac{L}{2}\right ) \right ) -1\right ) \\ & =\frac{L^{2}}{4\pi ^{2}n^{2}}\left ( \cos \left ( \pi n\right ) -1\right ) \end{align*}
Therefore\begin{align*} a_{n} & =-\frac{4}{L^{2}}\left ( \frac{L^{2}}{4\pi ^{2}n^{2}}\left ( \cos \left ( \pi n\right ) -1\right ) \right ) \\ & =\frac{1}{\pi ^{2}n^{2}}\left ( 1-\cos \left ( \pi n\right ) \right ) \end{align*}
The above is zero for even n and \frac{2L^{2}}{4\pi ^{2}n^{2}} for odd n. Therefore the above simplifies to a_{n}=\frac{2}{\pi ^{2}n^{2}}\qquad n=1,3,5,\cdots
The original function is in the red color. The plot shows that the convergence is fast (due to the \frac{1}{n^{2}} term). The convergence is uniform. After only 4 terms, the error between f\left ( x\right ) and its Fourier series approximation becomes very small. As expected, the error is largest at the top and at the lower corners where the original function changes more rapidly and therefore more terms would be needed in those regions compared to the straight edges regions of the function f\left ( x\right ) to get a better approximation.
The following is a plot of the function f\left ( x\right ) =e^{x}. In this plot, L=1 was used.
The Fourier series of f\left ( x\right ) = is given by\begin{equation} f\left ( x\right ) =\frac{a_{0}}{2}+\sum _{n=1}^{\infty }a_{n}\cos \left ( \frac{2\pi }{L}nx\right ) +b_{n}\sin \left ( \frac{2\pi }{L}nx\right ) \tag{1A} \end{equation}
And \begin{align} a_{n} & =\frac{2}{L}\int _{-\frac{L}{2}}^{\frac{L}{2}}f\left ( x\right ) \cos \left ( \frac{2\pi }{L}nx\right ) dx\nonumber \\ & =\frac{2}{L}\int _{-\frac{L}{2}}^{\frac{L}{2}}e^{x}\cos \left ( \frac{2\pi }{L}nx\right ) dx \tag{1} \end{align}
Integration by parts: Let u=\cos \left ( \frac{2\pi }{L}nx\right ) ,du=-\frac{2\pi n}{L}\sin \left ( \frac{2\pi }{L}nx\right ) and let dv=e^{x},v=e^{x}, therefore\begin{align*} I & =\int _{-\frac{L}{2}}^{\frac{L}{2}}e^{x}\cos \left ( \frac{2\pi }{L}nx\right ) dx\\ & =\left [ e^{x}\cos \left ( \frac{2\pi }{L}nx\right ) \right ] _{-\frac{L}{2}}^{\frac{L}{2}}-\int _{-\frac{L}{2}}^{\frac{L}{2}}-\frac{2\pi n}{L}\sin \left ( \frac{2\pi }{L}nx\right ) e^{x}dx\\ & =\left [ e^{\frac{L}{2}}\cos \left ( \frac{2\pi }{L}n\frac{L}{2}\right ) -e^{-\frac{L}{2}}\cos \left ( \frac{2\pi }{L}n\left ( -\frac{L}{2}\right ) \right ) \right ] +\frac{2\pi n}{L}\int _{-\frac{L}{2}}^{\frac{L}{2}}\sin \left ( \frac{2\pi }{L}nx\right ) e^{x}dx\\ & =\left [ e^{\frac{L}{2}}\cos \left ( \pi n\right ) -e^{-\frac{L}{2}}\cos \left ( \pi n\right ) \right ] +\frac{2\pi n}{L}\int _{-\frac{L}{2}}^{\frac{L}{2}}\sin \left ( \frac{2\pi }{L}nx\right ) e^{x}dx\\ & =\cos \left ( \pi n\right ) \left ( e^{\frac{L}{2}}-e^{-\frac{L}{2}}\right ) +\frac{2\pi n}{L}\int _{-\frac{L}{2}}^{\frac{L}{2}}\sin \left ( \frac{2\pi }{L}nx\right ) e^{x}dx\\ & =2\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) +\frac{2\pi n}{L}\int _{-\frac{L}{2}}^{\frac{L}{2}}\sin \left ( \frac{2\pi }{L}nx\right ) e^{x}dx \end{align*}
Integration by parts again, let u=\sin \left ( \frac{2\pi }{L}nx\right ) ,du=\frac{2\pi n}{L}\cos \left ( \frac{2\pi }{L}nx\right ) and dv=e^{x},v=e^{x}. The above becomes I=2\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) +\frac{2\pi n}{L}\left ( \left [ e^{x}\sin \left ( \frac{2\pi }{L}nx\right ) \right ] _{-\frac{L}{2}}^{\frac{L}{2}}-\int _{-\frac{L}{2}}^{\frac{L}{2}}\frac{2\pi n}{L}\cos \left ( \frac{2\pi }{L}nx\right ) e^{x}dx\right )
Since \int _{-\frac{L}{2}}^{\frac{L}{2}}\cos \left ( \frac{2\pi }{L}nx\right ) e^{x}dx=I the above reduces to\begin{align*} I & =2\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) -\frac{4\pi ^{2}n^{2}}{L^{2}}I\\ I\left ( 1+\frac{4\pi ^{2}n^{2}}{L^{2}}\right ) & =2\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) \\ I & =\frac{2\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) }{1+\frac{4\pi ^{2}n^{2}}{L^{2}}} \end{align*}
Using the above in (1) gives\begin{align*} a_{n} & =\frac{2}{L}\frac{2\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) }{1+\frac{4\pi ^{2}n^{2}}{L^{2}}}\\ & =\frac{2L^{2}}{L}\frac{2\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) }{L^{2}+4\pi ^{2}n^{2}}\\ & =\frac{4L}{L^{2}+4\pi ^{2}n^{2}}\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) \end{align*}
Next, b_{n}\, is found:\begin{align} b_{n} & =\frac{2}{L}\int _{-\frac{L}{2}}^{\frac{L}{2}}f\left ( x\right ) \sin \left ( \frac{2\pi }{L}nx\right ) dx\nonumber \\ & =\frac{2}{L}\int _{-\frac{L}{2}}^{\frac{L}{2}}e^{x}\sin \left ( \frac{2\pi }{L}nx\right ) dx \tag{2} \end{align}
Integration by parts: Let u=\sin \left ( \frac{2\pi }{L}nx\right ) ,du=\frac{2\pi n}{L}\sin \left ( \frac{2\pi }{L}nx\right ) and let dv=e^{x},v=e^{x}, therefore\begin{align*} I & =\int _{-\frac{L}{2}}^{\frac{L}{2}}e^{x}\sin \left ( \frac{2\pi }{L}nx\right ) dx\\ & =\left [ e^{x}\sin \left ( \frac{2\pi }{L}nx\right ) \right ] _{-\frac{L}{2}}^{\frac{L}{2}}-\int _{-\frac{L}{2}}^{\frac{L}{2}}\frac{2\pi n}{L}\cos \left ( \frac{2\pi }{L}nx\right ) e^{x}dx \end{align*}
But \left [ e^{x}\sin \left ( \frac{2\pi }{L}nx\right ) \right ] _{-\frac{L}{2}}^{\frac{L}{2}} goes to zero as \sin \left ( \pi n\right ) =0 for integer n and the above simplifies to I=-\frac{2\pi n}{L}\int _{-\frac{L}{2}}^{\frac{L}{2}}\cos \left ( \frac{2\pi }{L}nx\right ) e^{x}dx
But \int _{-\frac{L}{2}}^{\frac{L}{2}}\sin \left ( \frac{2\pi }{L}nx\right ) e^{x}dx=I and the above reduces to\begin{align*} I & =-\frac{2\pi n}{L}\left ( 2\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) +\frac{2\pi n}{L}I\right ) \\ I & =-\frac{4\pi n}{L}\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) -\frac{4\pi ^{2}n^{2}}{L^{2}}I\\ I\left ( 1+\frac{4\pi ^{2}n^{2}}{L^{2}}\right ) & =-\frac{4\pi n}{L}\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) \\ I & =\frac{-\frac{4\pi n}{L}\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) }{1+\frac{4\pi ^{2}n^{2}}{L^{2}}}\\ & =\frac{-4\pi nL\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) }{L^{2}+4\pi ^{2}n^{2}} \end{align*}
Using the above in (2) gives\begin{align*} b_{n} & =\frac{2}{L}\frac{-4\pi nL\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) }{L^{2}+4\pi ^{2}n^{2}}\\ & =\frac{-8\pi n}{L^{2}+4\pi ^{2}n^{2}}\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) \end{align*}
Therefore, from (1A) the Fourier series is\begin{equation} f\left ( x\right ) =\frac{2}{L}\sinh \left ( \frac{L}{2}\right ) +\sum _{n=1}^{\infty }\frac{4L}{L^{2}+4\pi ^{2}n^{2}}\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) \cos \left ( \frac{2\pi }{L}nx\right ) -\frac{8\pi n}{L^{2}+4\pi ^{2}n^{2}}\cos \left ( \pi n\right ) \sinh \left ( \frac{L}{2}\right ) \sin \left ( \frac{2\pi }{L}nx\right ) \tag{3} \end{equation}
Compared to part (1), more terms are needed here to get good approximation. Since the original function is piecewise continuous when extending over multiple periods, the convergence is no longer a uniform convergence. At the point of discontinuity, the approximation converges to the average value of the original function at that point. At about 20 terms the approximation started to give good results. Due to Gibbs phenomena, at the points of discontinuities, the error is largest. Here is a plot showing one period
In the following plot, 3 periods are shown to make it easier to see the effect of discontinuities and the Gibbs phenomena
Find the general solution of
Solution
This ODE is not separable and it is also not exact (It was checked for exactness and failed the test). The ODE is next checked to see if it is isobaric. An ODE y^{\prime }=f\left ( x,y\right ) is isobaric (which is a generalization of a homogeneous ODE) if the substitution y\left ( x\right ) =v\left ( x\right ) x^{m}
Adding the weights of the first term above gives 2x^{3}dy\rightarrow 3+m. The next term weight is dx\rightarrow 1. The next term weight is \sqrt{1+4x^{2}y}dx\rightarrow \frac{1}{2}\left ( 2+m\right ) +1=2+\frac{m}{2}. Therefore the weights of each term are \{3+m,1,2+\frac{m}{2}\}
Solving this ODE for v\left ( x\right ) \frac{dv}{1+\sqrt{1+4v}+4v}=\frac{1}{2x}dx
Using this result in (2) gives the following (the absolute values are removed because the constant of integration absorbs the sign).\begin{align*} \frac{1}{2}\ln \left ( 1+u\right ) & =\frac{1}{2}\ln x+c\\ \ln \left ( 1+u\right ) & =\ln x+2c \end{align*}
Let 2c=C_{0} be a new constant. The above becomes\begin{align*} \ln \left ( 1+u\right ) & =\ln x+C_{0}\\ e^{\ln \left ( 1+u\right ) } & =e^{\ln x+C_{0}}\\ 1+u & =e^{C_{0}}x\\ 1+u & =Cx \end{align*}
Where C=e^{C_{0}} is a new constant. Therefore the solution is u\left ( x\right ) =Cx-1
But y=\frac{v}{x^{2}} therefore the above gives the final solution as y\left ( x\right ) =\frac{\left ( Cx-1\right ) ^{2}-1}{4x^{2}}
e^{x}\sin y-2y\sin x+\left ( y^{2}+e^{x}\cos y+2\cos x\right ) y^{\prime }=0
Next, the ODE is determined if it is exact or not. The ODE is exact if the following condition is satisfied \frac{\partial M}{\partial y}=\frac{\partial N}{\partial x}
Because \frac{\partial M}{\partial y}=\frac{\partial N}{\partial x}, then the ODE is exact. The following equations are used to solve for the function \phi \left ( x,y\right ) \begin{align} \frac{\partial \phi }{\partial x} & =M=e^{x}\sin y-2\,y\sin x\tag{3}\\ \frac{\partial \phi }{\partial y} & =N={y}^{2}+e^{x}\cos y+2\,\cos x \tag{4} \end{align}
Integrating (3) w.r.t x gives \begin{align} \int \frac{\partial \phi }{\partial x}dx & =\int e^{x}\sin y-2\,y\sin xdx\nonumber \\ \phi \left ( x,y\right ) & =e^{x}\sin y+2\,y\cos x+f(y) \tag{5} \end{align}
Where f(y) is used as the constant of integration because \phi \left ( x,y\right ) is a function of both x and y. Taking derivative of (5) w.r.t y gives\begin{equation} \frac{\partial \phi }{\partial y}=e^{x}\cos y+2\,\cos x+f^{\prime }(y) \tag{6} \end{equation}
Where C_{1} is constant of integration. Substituting the value of f(y) back into (5) gives \phi \left ( x,y\right ) \phi =e^{x}\sin y+2\,y\cos x+\frac{1}{3}\,{y}^{3}+C_{1}
y^{\prime }+y\cos x=\frac{1}{2}\sin \left ( 2x\right )
The above integral can be solved as follows. Since \sin \left ( 2x\right ) =2\sin x\cos x therefore then I=\frac{1}{2}\int e^{\sin x}\sin \left ( 2x\right ) dx=\int e^{\sin x}\sin x\cos xdx
Since z=\sin x the above reduces to I=e^{\sin x}\left ( \sin \left ( x\right ) -1\right )
Find general solution of
Solution
y^{\prime \prime \prime }-4y^{\prime \prime }-4y^{\prime }=8\sin x-16
Hence the solution to (1) is given by linear combinations of e^{\lambda _{1}x},e^{\lambda _{2}x} as u_{h}\left ( x\right ) =c_{1}e^{2\left ( 1+\sqrt{2}\right ) x}+c_{2}e^{2\left ( 1-\sqrt{2}\right ) x}
To simplify the above, let \frac{c_{1}}{2\left ( 1+\sqrt{2}\right ) }=C_{1},\frac{c_{2}}{2\left ( 1-\sqrt{2}\right ) }=C_{2}, where C_{1},C_{2} are new constants. The above simplifies to y_{h}=C_{1}e^{2\left ( 1+\sqrt{2}\right ) x}+C_{2}e^{\left ( 2-2\sqrt{2}\right ) x}+C_{3}
Substituting these back into the original ODE y^{\prime \prime \prime }-4y^{\prime \prime }-4y^{\prime }=8\sin x-16 gives\begin{align*} \left ( -A\cos x+B\sin x\right ) -4\left ( -A\sin x-B\cos x\right ) -4\left ( k+A\cos x-B\sin x\right ) & =8\sin x-16\\ -A\cos x+B\sin x+4A\sin x+4B\cos x-4A\cos x+4B\sin x-4k & =8\sin x-16\\ \cos x\left ( -A+4B-4A\right ) +\sin x\left ( B+4A+4B\right ) -4k & =8\sin x-16\\ \cos x\left ( -5A+4B\right ) +\sin x\left ( 5B+4A\right ) -4k & =8\sin x-16 \end{align*}
Comparing coefficients gives the following equations to solve for the unknowns A,B,k\begin{align*} -4k & =-16\\ -5A+4B & =0\\ 5B+4A & =8 \end{align*}
The second equation gives B=\frac{5}{4}A. Using this in the third equation gives 5\left ( \frac{5}{4}A\right ) +4A=8, solving gives A=\frac{32}{41}. Hence B=\frac{5}{4}\left ( \frac{32}{41}\right ) =\frac{40}{41}. The first equation gives k=4. Therefore the particular solution is\begin{align*} y_{p} & =A\sin x+B\cos x+kx\\ & =\frac{32}{41}\sin x+\frac{40}{41}\cos x+4x \end{align*}
Now that y_{h} and y_{p} are found, the general solution is found as \begin{align*} y & =y_{h}+y_{p}\\ & =C_{1}e^{2\left ( 1+\sqrt{2}\right ) x}+C_{2}e^{\left ( 2-2\sqrt{2}\right ) x}+C_{3}+\frac{32}{41}\sin x+\frac{40}{41}\cos x+4x \end{align*}
Where C_{1},C_{2} are the two constants of integration.
a^{2}y^{\prime 2}=\left ( 1+y^{\prime 2}\right ) ^{3}
Hence the polynomial is A^{6}+3A^{4}+A^{2}\left ( 3-a^{2}\right ) +1=0
\begin{align*} B_{1} & =\sqrt [3]{\sqrt{\frac{1}{4}a^{4}-\frac{1}{27}a^{6}}-\frac{1}{2}a^{2}}+\frac{1}{3}\frac{a^{2}}{\sqrt [3]{\sqrt{\frac{1}{4}a^{4}-\frac{1}{27}a^{6}}-\frac{1}{2}a^{2}}}-1\\ B_{2} & =\frac{1}{2}i\sqrt{3}\left ( \sqrt [3]{\sqrt{\frac{1}{4}a^{4}-\frac{1}{27}a^{6}}-\frac{1}{2}a^{2}}-\frac{1}{3}\frac{a^{2}}{\sqrt [3]{\sqrt{\frac{1}{4}a^{4}-\frac{1}{27}a^{6}}-\frac{1}{2}a^{2}}}\right ) -\frac{1}{2}\sqrt [3]{\sqrt{\frac{1}{4}a^{4}-\frac{1}{27}a^{6}}-\frac{1}{2}a^{2}}-\frac{1}{6}\frac{a^{2}}{\sqrt [3]{\sqrt{\frac{1}{4}a^{4}-\frac{1}{27}a^{6}}-\frac{1}{2}a^{2}}}-1\\ B_{3} & =-\frac{1}{2}\sqrt [3]{\sqrt{\frac{1}{4}a^{4}-\frac{1}{27}a^{6}}-\frac{1}{2}a^{2}}-\frac{1}{2}i\sqrt{3}\left ( \sqrt [3]{\sqrt{\frac{1}{4}a^{4}-\frac{1}{27}a^{6}}-\frac{1}{2}a^{2}}-\frac{1}{3}\frac{a^{2}}{\sqrt [3]{\sqrt{\frac{1}{4}a^{4}-\frac{1}{27}a^{6}}-\frac{1}{2}a^{2}}}\right ) -\frac{1}{6}\frac{a^{2}}{\sqrt [3]{\sqrt{\frac{1}{4}a^{4}-\frac{1}{27}a^{6}}-\frac{1}{2}a^{2}}}-1 \end{align*}
Therefore A_{1}=\pm \sqrt{B_{1}},A_{2}=\pm \sqrt{B_{2}},A_{3}=\pm \sqrt{B_{3}} or, since y^{\prime }\left ( x\right ) =A\,, then there are 6 solutions, each is a solution for one root.\begin{align*} \frac{dy_{1}}{dx} & =+\sqrt{B_{1}}\\ \frac{dy_{2}}{dx} & =-\sqrt{B_{1}}\\ \frac{dy_{3}}{dx} & =+\sqrt{B_{2}}\\ \frac{dy_{4}}{dx} & =-\sqrt{B_{2}}\\ \frac{dy_{5}}{dx} & =+\sqrt{B_{3}}\\ \frac{dy_{6}}{dx} & =-\sqrt{B_{3}} \end{align*}
But the roots \pm B_{i} are constants. Therefore each of the above can be solved by direct integration. The final solution which gives the solutions\begin{align*} y_{1} & =\sqrt{B_{1}}x+C_{1}\\ y_{2} & =-\sqrt{B_{1}}x+C_{2}\\ y_{3} & =\sqrt{B_{2}}x+C_{3}\\ y_{4} & =-\sqrt{B_{2}}x+C_{4}\\ y_{5} & =\sqrt{B_{3}}x+C_{5}\\ y_{6} & =-\sqrt{B_{3}}x+C_{6} \end{align*}
Where the constants B_{i} are given above.