# Solving pde with homogenous neumann boundary condition using fourier series

I have the following diffusion problem: \begin{align*} &\frac{\partial u}{\partial t} - \frac{\partial^2 u}{\partial x^2} = -Cu,\;\; 0 \leq x \leq L, \; t\geq 0,\\ &\frac{\partial u}{\partial x}(0, t)= \frac{\partial u}{\partial x}(L, t)=0,\; t\geq0,\\ &u(x,0)= \begin{cases} u_0, & 0 Since we have homogenous Neumann boundary condition I make the ansatz: $$u(x,t) = C_0 + \sum _{k = 1} ^{\infty}\beta_k(t)\cos\left(\frac{k\pi}{L}x\right),$$ and with the pde I have: $$\sum _{k = 1} ^{\infty}\left(\beta'_k(t)+D\frac{k^{2}\pi^{2}}{L^{2}}\beta_k(t)\right)\cos\left(\frac{k\pi}{L}x\right)=-CC_0 - C\sum _{k = 1} ^{\infty}\beta_k(t)\cos\left(\frac{k\pi}{L}x\right).$$

And this is where I am stuck. The constant $$-CC_0$$ seems to cause trouble. Without it I would just solve $$\beta'_k(t)+D\frac{k^{2}\pi^{2}}{L^{2}}\beta_k(t)\cos\left(\frac{k\pi}{L}x\right)=-C\beta_k(t)$$ to find $$\beta_k$$, but with the constant I am not sure. Thanks in advance!

• Then don't include the constant $C_{0}$, just start the summation at $k = 0$. Or make the transformation $u = e^{-Ct} v$ first and then solve the new problem in $v$. Feb 11, 2022 at 4:43
• So make an ansatz without $C_0$ or just not include the constant in the right hand side? Feb 11, 2022 at 9:20

Try using separation of variables. Assuming solutions $$u(x,t)=X(x)T(t).$$ Substituting into the equation gives $$X(x)T'(t)-X''(x)T(t)=-CX(x)T(t)$$ Dividing by $$X(x)T(t)$$ gives $$\frac{T'}{T}-\frac{X''}{X}=-C \\ \frac{T'}{T}+C=\frac{X''}{X}$$ So there is a separation constant $$\lambda$$ such that $$\frac{T'}{T}+C=\lambda,\;\; \lambda=\frac{X''}{X}.$$ The endpoint conditions for $$X$$ on $$[0,L]$$ have the form $$X'(0)=0,\;\; X'(L)=0.$$ The $$X$$ solutions have the form $$X(x)=A_n\cos(n\pi x/L)$$ with corresponding values of $$\lambda_n = -n^2\pi^2/L^2,\;\;n=0,1,2,3,\cdots.$$ The related solutions in $$T$$ are found by solving $$\frac{T'}{T}=-n^2\pi^2/L^2-C \\ T(t) = \exp\{(-n^2\pi^2/L^2-C)t\}$$ The general separated solution becomes $$u(x,t) = \sum_{n=0}^{\infty}A_n\cos(n\pi x/L)\exp\{(-n^2\pi^2/L^2-C)t\}$$ The constants $$A_n$$ are determined by the initial condition $$u(x,0)=\sum_{n=0}^{\infty}A_n\cos(n\pi x/L).$$ The coefficients in this expansion are Fourier coefficients of $$u(x,0)$$ with respect to the basis functions $$\cos(n\pi x/L)$$ for $$n=0,1,2,3,\cdots$$. The function $$u(x,0)$$ is given in the problem. So the $$A_n$$ are known; they are the Fourier cosine coefficients.
Try using separation of variables. Assuming solutions $$u(x,t)=X(x)T(t).$$ Substituting into the equation gives $$X(x)T'(t)-X''(x)T(t)=-CX(x)T(t)$$ Dividing by $$X(x)T(t)$$ gives $$\frac{T'}{T}-\frac{X''}{X}=-C \\ \frac{T'}{T}+C=\frac{X''}{X}$$ So there is a separation constant $$\lambda$$ such that $$\frac{T'}{T}+C=\lambda,\;\; \lambda=\frac{X''}{X}.$$ The endpoint conditions for $$X$$ on $$[0,L]$$ have the form $$X'(0)=0,\;\; X'(L)=0.$$ The $$X$$ solutions have the form $$X(x)=A_n\cos(n\pi x/L)$$ with corresponding values of $$\lambda_n = -n^2\pi^2/L^2,\;\;n=0,1,2,3,\cdots.$$ The related solutions in $$T$$ are found by solving $$\frac{T'}{T}=-n^2\pi^2/L^2-C \\ T(t) = \exp\{(-n^2\pi^2/L^2-C)t\}$$ The general separated solution becomes $$u(x,t) = \sum_{n=0}^{\infty}A_n\cos(n\pi x/L)\exp\{(-n^2\pi^2/L^2-C)t\}$$ The constants $$A_n$$ are determined by the initial condition $$u(x,0)=\sum_{n=0}^{\infty}A_n\cos(n\pi x/L).$$ The coefficients in this expansion are Fourier coefficients of $$u(x,0)$$ with respect to the basis functions $$\cos(n\pi x/L)$$ for $$n=0,1,2,3,\cdots$$. The function $$u(x,0)$$ is given in the problem. So the $$A_n$$ are known; they are the Fourier cosine coefficients $$A_n$$ in the cosine series expansion of $$u(x,0)$$.