# Second order inhomogeneous ODE

Solve the BVP $$\begin{cases} u''+a^2u=\sin\pi x, 0<x<1 \\ u(0)=1,\quad u(1)=-2 \end{cases}$$ for all $a\in\mathbb{R}$. What are the solutions in the cases $a=\pm\pi$.

Given that the BVP is a second-order inhomogeneous ODE, we find the characteristic equation to be in the form $$r^2+a^2=0\implies r=\pm ai.$$

The homogeneous equation is $$u_h=C_1\cos(ax)+C_2\sin(ax).$$

The particular equation is $$u_p=C_3x\sin(\pi x)+C_4x\cos(\pi x),$$ $$u_p'=-C_3\pi x\cos(\pi x)+C_3\sin(\pi x)-C_4\pi x\sin(\pi x)+C_4\cos(\pi x),$$ $$u_p''=-C_3\pi^2 x\sin(\pi x)+2C_3\pi\cos(\pi x)-2C_4\pi\sin(\pi x)-C_4\pi^2 x\cos(\pi x).$$

Substituting for the given ODE, we have \begin{multline*} u_p''+\pi^2u = -C_3\pi^2 x\sin(\pi x)+2C_3\pi\cos(\pi x)-2C_4\sin(\pi x)-C_4\pi^2 x\cos(\pi x) \\ +\pi^2(C_3x\sin(\pi x)+C_4x\cos(\pi x))=\sin(\pi x), \end{multline*}

and we get $C_3=0$ and $C_4=-\frac{1}{2\pi}$. Then the general solution is, $$u=u_h+u_p=C_1\cos(ax)+C_2\sin(ax)-\frac{1}{2\pi}x\cos(\pi x)$$

Using the given initial conditions, we get $C_1=1$ and $C_2=\frac{-2-\frac{1}{2\pi}-\cos(a)}{\sin(a)}$. Then the general solution is,

$$u=u_h+u_p=\cos(ax)+\frac{-2-\frac{1}{2\pi}-\cos(a)}{\sin(a)}\sin(ax)-\frac{1}{2\pi}x\cos(\pi x)$$

Note that if $a=\pm\pi$ then $\sin(\pm\pi)=0$, which indicates $u$ is undefined at $a=\pm\pi$.

• What are you asking? – Chappers Feb 22 '17 at 20:35
• @Chappers, sorry. I edited the post. – ozarka Feb 22 '17 at 20:36
• There is a mistake when differentiating $C_3 x \sin(\pi x)$. The first minus sign must not be there. – Shashi Feb 23 '17 at 6:19
• @Shashi, thank you. But this doesn't change anything since the term $x\sin(\pi x)$ vanishes anyway when I plug it into the BVP because on the right hand side we only have the term $x\sin(\pi x)$. – ozarka Feb 23 '17 at 6:29
• @ozarka are you sure that $u(1)=-2$ is given instead of $u'(1)=-2$? I think that it must be $u'(1)=-2$ – Shashi Feb 23 '17 at 6:49

Hint:

For $a=\pm \pi$, try: \begin{align*}u_I(x)=Ax\sin(\pi x) +Bx \cos(\pi x) \end{align*} for the inhomogeneous part. Calculate $u''_I$ and put it in the equation to find the constants $A$ and $B$.

For $a\neq \pm \pi$, try: \begin{align*} u_I(x)=A\sin(a x) +B \cos(a x) \end{align*}

I hope you can finish it from here.

• Thank you. To confirm is the homogeneous solution $C_1\sin(ax)+C_2\cos(ax)$ the same for both $a=\pm\pi$ and $a\neq\pm\pi$? – ozarka Feb 23 '17 at 3:09
• @ozarka yes! The homogeneous part remains the same. – Shashi Feb 23 '17 at 5:49
• Could you check my new attempt? I feel like my constant $C_2$ is wrong because $u$ is being undefined when $a=\pm\pi$. – ozarka Feb 23 '17 at 6:04