Solving the BVP $u_{xx}+a^2u=\sin(\pi x)$ with $u(0)=1$ and $u(1)=-2$

boundary value problemordinary differential equationsproof-verification

I am trying to solve the BVP $$u_{xx}+a^2u=\sin(\pi x), \ \ \text{for} \ \ 0<x<1$$ with $u(0)=1$ and $u(1)=-2$, $\forall a\in\mathbb{R}$.

I begin by solving the homogeneous equation $u_{xx}+a^2u=0$. The roots of the characteristic equation of this ODE are $\pm ai$ and so the general solution of the homogeneous equation is $$u_H(x)=A\cos(ax)+B\sin(ax), \ \ A,B\in\mathbb{R}.$$ Searching for a particular solution, I guessed that $u_p(x)=x(C_1\cos(\pi x)+C_2\sin(\pi x))$ where $C_1,C_2\in\mathbb{R}$. So,
\begin{align}
u'_p(x)&=-C_1x\pi\sin(\pi x)+C_1\cos(\pi x)+C_2x\pi\cos(\pi x)+C_2\sin(\pi x) \\
u''_p(x)&=-C_1\pi^2 x\cos(\pi x)-2C_1\pi\sin(\pi x)-C_2\pi x\sin(\pi x)+2C_2\pi\cos(\pi x).
\end{align}

Substitution into the original ODE gives $C_1=-\frac{1}{2\pi}$ and $C_2=0$ and so $$u_p(x)=-\frac{x}{2\pi}\cos(\pi x).$$
Thus, $$u(x)=u_H(x)+u_P(x)=A\cos(ax)+B\sin(ax)-\frac{x}{2\pi}\cos(\pi x).$$
The boundary condition $u(0)=1$ implies $A=1$. The boundary condition $u(1)=-2$ implies \begin{align}
-2&=\cos(a)+B\sin(a)-\frac{1}{2\pi}\cos(\pi) \\
\implies B&=\frac{1}{\sin(a)}\left(-2-\frac{1}{2\pi}-\cos(a)\right).
\end{align}

Hence, $$u(x)=\cos(ax)+\frac{1}{\sin(a)}\left(-2-\frac{1}{2\pi}-\cos(a)\right)\sin(ax)-\frac{x}{2\pi}\cos(\pi x).$$
But the resource I found this question states that this is not the correct answer. Have I made an error in logic?

Best Answer

In the general case $|a|\ne \pi$ there is no resonance in the forcing term on the right and you get the solution by the method of undetermined coefficients in the base case, that is, $$u_p(x)=C_1\cos(πx)+C_2\sin(πx).$$ This results in $C_1=0$ and $(-\pi^2+a^2)C_2=1$.


Inserting boundary conditions into $$u(x)=A\cos(ax)+B\sin(ax)+\frac1{a^2-\pi^2}\sin(πx)$$ gives $1=A$ and $-2=\cos(a)+B\sin(a)$, $B=-\frac{2+\cos(a)}{\sin(a)}$. Thus in general there will be no solutions for $a=k\pi$.


For $a\approx \pi$ one can write the solution as $$ u(x)=\cos(ax)-\frac{\sin(a)\sin(ax)}{1+\cos(a-\pi)}-\frac{\sin(ax)-\sin(πx)}{(a-π)(a+π)}+\left(\frac1{a^2-π^2}+\frac1{\sin(a-π)}\right)\sin(ax) $$ While the first three terms have a limit for $a\toπ$, the last coefficient does not cancel the two poles in its terms, thus is singular. There is no solution for $a=\pi$.

Related Question