Solve the boundary value problem y'' + y = 2x - π , with…
Solve the boundary value problem $y'' + y = 2x - \pi$, with $y(0)=0, \qquad y(\pi)=0$.
Explanation of Method
Because sin x solves the homogeneous problem and vanishes at both endpoints, the BVP has infinitely many solutions, existing only because 2x−π is orthogonal to sin x on [0,π].
Step 1: Homogeneous solution
\[ r^2+1=0 \implies r=\pm i \implies Y_h = C_1\cos x + C_2\sin x. \]
Step 2: Particular solution
The right-hand side is linear in $x$, so try $y^*=Ax+B$: \[0 + Ax + B = 2x-\pi \implies A=2,\ B=-\pi, \qquad y^*=2x-\pi.\]
Step 3: General solution
\[ y = C_1\cos x + C_2\sin x + 2x - \pi. \]
Step 4: Apply the boundary conditions
From $y(0)=0$: $C_1 - \pi = 0 \implies C_1 = \pi.$
From $y(\pi)=0$, using $\cos\pi=-1,\ \sin\pi=0$: \[-C_1 + C_2\cdot 0 + 2\pi-\pi = 0 \implies -C_1+\pi=0 \implies C_1=\pi,\]
the same condition as before — it is automatically satisfied and places no restriction on $C_2$. So $C_2$ remains an arbitrary constant.
Step 5: Verify
With $y=\pi\cos x+C_2\sin x+2x-\pi$: $y'=-\pi\sin x+C_2\cos x+2$, $y''=-\pi\cos x-C_2\sin x$, so $y''+y=-\pi\cos x-C_2\sin x+\pi\cos x+C_2\sin x+2x-\pi=2x-\pi. $\checkmark$$ Also $y(0)=\pi-\pi=0\ \checkmark$ and $y(\pi)=-\pi+2\pi-\pi=0\ \checkmark$, both independent of $C_2$.
Step 6: Solution
The solution is recorded in the result below.
Result
Final answer:
\[\boxed{\,y = \pi\cos x + C_2\sin x + 2x - \pi, \qquad C_2 \text{ arbitrary}\,}\]
Remark
Why infinitely many solutions. Since $r=\pm i$ are roots of the characteristic equation, $\sin x$ itself solves the homogeneous equation $y''+y=0$, and it happens to satisfy both boundary conditions: $\sin0=0$ and $\sin\pi=0$. This is a resonance/degenerate boundary-condition scenario: the homogeneous problem $y''+y=0,\ y(0)=y(\pi)=0$ already has the nontrivial solution $y=\sin x$, so the boundary conditions cannot pin down $C_2$.
The inhomogeneous BVP is solvable here only because the right-hand side $2x-\pi$ is orthogonal to $\sin x$ on $[0,\pi]$ — a Fredholm alternative compatibility condition. Checking it directly:
\[ \int_0^\pi x\sin x\,dx = \bigl[-x\cos x\bigr]_0^\pi + \int_0^\pi\cos x\,dx = \pi + \bigl[\sin x\bigr]_0^\pi = \pi+0=\pi, \]
\[ \int_0^\pi \sin x\,dx = \bigl[-\cos x\bigr]_0^\pi = 1-(-1)=2, \]
\[ \int_0^\pi (2x-\pi)\sin x\,dx = 2\pi - \pi\cdot2 = 2\pi-2\pi = 0.\ \checkmark \]
Had the right-hand side not been orthogonal to $\sin x$ on $[0,\pi]$, this compatibility integral would be nonzero and the BVP would have no solution at all.