Problem 223
Medium Initial-Value Problems

Consider y'' + k^2 y = f(x), k ∈ mathbbR, k ≠ 0 . Show that…

Consider $y'' + k^2 y = f(x), \qquad k \in \mathbb{R},\ k \neq 0$. Show that the general solution can be written as $ \displaystyle y = A\cos(kx) + B\sin(kx) + \frac{1}{k}\int_{x_0}^{x} f(t)\sin\bigl(k(x-t)\bigr)\,dt $, where $A, B$ are integration constants and $x_0$ is a fixed reference point.

Explanation of Method

Deriving the closed-form solution of the driven harmonic oscillator as a convolution with the Green's function

Step 1: The homogeneous solution

The associated homogeneous equation $y'' + k^2 y = 0$ has characteristic equation $r^2 + k^2 = 0$, with roots $r = \pm ik$. Since $k$ is real and nonzero, these are a complex-conjugate pair, and the homogeneous solution is the familiar oscillatory pair

\[ y_h(x) = A\cos(kx) + B\sin(kx). \]

Step 2: Variation of parameters

We seek a particular solution of the form $y_p = u_1(x)\cos(kx) + u_2(x)\sin(kx)$, where $u_1, u_2$ are functions to be determined subject to the usual auxiliary constraint that kills the second-derivative cross terms. This gives the linear system

\[ \begin{aligned} u_1'\cos(kx) + u_2'\sin(kx) &= 0, \\[2pt] -k\,u_1'\sin(kx) + k\,u_2'\cos(kx) &= f(x). \end{aligned} \]

The coefficient matrix of this system is exactly the Wronskian matrix of $\cos(kx)$ and $\sin(kx)$, whose determinant is

\[ W(x) = \cos(kx)\cdot k\cos(kx) - \bigl(-k\sin(kx)\bigr)\sin(kx) = k \neq 0, \]

a nonzero constant, so the system is solvable everywhere. Solving by Cramer's rule (or direct elimination) yields

\[ u_1'(x) = -\frac{f(x)\sin(kx)}{k}, \qquad u_2'(x) = \frac{f(x)\cos(kx)}{k}. \]

Integrating from the reference point $x_0$ to $x$ — which fixes the arbitrary constants of integration to be absorbed into $A$ and $B$ later — gives, with $t$ as the dummy integration variable,

\[ u_1(x) = -\frac{1}{k}\int_{x_0}^{x} f(t)\sin(kt)\,dt, \qquad u_2(x) = \frac{1}{k}\int_{x_0}^{x} f(t)\cos(kt)\,dt. \]

Step 3: Assembling the particular solution

Substituting $u_1$ and $u_2$ back into $y_p = u_1\cos(kx) + u_2\sin(kx)$ and combining the two integrals (they share the same limits and the same dummy variable $t$): $y_p(x) = \frac{1}{k}\int_{x_0}^{x} f(t)\Bigl[\sin(kx)\cos(kt) - \cos(kx)\sin(kt)\Bigr]dt$.

The bracketed expression is exactly the sine-subtraction identity $\sin(kx)\cos(kt) - \cos(kx)\sin(kt) = \sin\bigl(k(x-t)\bigr)$, so

\[ y_p(x) = \frac{1}{k}\int_{x_0}^{x} f(t)\,\sin\bigl(k(x-t)\bigr)\,dt. \]

Step 4: The general solution

Adding the homogeneous solution to $y_p$ produces the claimed general solution of the forced oscillator equation: $y(x) = A\cos(kx) + B\sin(kx) + \frac{1}{k}\int_{x_0}^{x} f(t)\,\sin\bigl(k(x-t)\bigr)\,dt$.

Step 5: Direct verification via Leibniz's rule

It is worth checking this formula directly rather than relying only on the derivation. Write $y_p(x) = \frac{1}{k}\int_{x_0}^{x} f(t)\sin\bigl(k(x-t)\bigr)dt$. Since the integrand vanishes at the upper limit $t = x$ (because $\sin(k(x-x)) = \sin 0 = 0$), differentiating under the integral sign via Leibniz's rule produces no boundary contribution at first order:

\[ y_p'(x) = \frac{1}{k}\int_{x_0}^{x} f(t)\,k\cos\bigl(k(x-t)\bigr)\,dt = \int_{x_0}^{x} f(t)\cos\bigl(k(x-t)\bigr)\,dt. \]

Differentiating once more, now the boundary term at $t=x$ contributes $f(x)\cos(0) = f(x)$: $y_p''(x) = f(x) - \int_{x_0}^{x} f(t)\,k\sin\bigl(k(x-t)\bigr)\,dt = f(x) - k^2 y_p(x)$.

Hence $y_p'' + k^2 y_p = f(x)$ exactly, confirming $y_p$ is a genuine particular solution. Since $y_h'' + k^2 y_h = 0$ trivially, the sum $y = y_h + y_p$ satisfies the full inhomogeneous equation, and the two free constants $A, B$ let it match any prescribed initial data.


Result

Final answer:

\[\boxed{\,y(x) = A\cos(kx) + B\sin(kx) + \frac{1}{k}\int_{x_0}^{x} f(t)\,\sin\bigl(k(x-t)\bigr)\,dt\,}\]

Remark

Remark. The structure $y = y_h + y_p$ is the standard split into free oscillation and forced response. The integral term is a convolution of the forcing $f$ with the Green's function $G(x,t) = \sin\bigl(k(x-t)\bigr)/k$ of the operator $d^2/dx^2 + k^2$ with respect to the point $x_0$. Because $y_p(x_0) = 0$ trivially (the integral collapses to zero) and $y_p'(x_0) = \int_{x_0}^{x_0} f\,dt = 0$ as well, the particular solution contributes nothing to the initial data at $x_0$; the constants $A$ and $B$ are therefore fixed purely by $y(x_0)$ and $y'(x_0)$, independent of the forcing.