Given the following initial value problem (IVP) $$ y'' + a y = f(x), \qquad y(0)= y'(0) = 0$$ show that $$y = \frac1a \int_{0}^{x}f(t)\sin(ax-at)\ {\rm d}t$$
My attempt
To solve the given initial value problem $$y''+ay=f(x)$$ we first solve the homogeneous equation $$y''+ay=0$$ The characteristic equation is $r^2+a=0$, which has roots $r=\pm\sqrt{-a}$. Depending on the sign of $a$, these roots can be written as complex numbers or real numbers.
If $a<0$, we can write the roots as $r=\pm i\sqrt{a}$. In this case, the general solution to the homogeneous equation is $$y_h(x) = c_1\cdot \cos\sqrt{-a}x + c_2\sin\sqrt{-a}x$$
If $a>0$, we can write the roots as $r=±\sqrt(a)$. In this case, the general solution to the homogeneous equation is $$y_h(x) = c_1\cdot e^{-\sqrt{a}x)} + c_2e^{\sqrt{a}x}$$
Proceeding as such only the former case yields the correct result. What about the latter?
The solution you show is actually wrong. Here is the correct one. The $a$ is the final solution should be $\sqrt a$.
$$ y^{\prime\prime}+ay=f(x) $$
The solution to $y_{h}$ is $c_{1}\cos\left( \sqrt{a}x\right) +c_{2}% \sin\left( \sqrt{a}x\right) $. Hence the basis solutions are $y_{1}% =\cos\left( \sqrt{a}x\right) ,y_{2}=\sin\left( \sqrt{a}x\right) $. $y_{p}$ is found using variation of parameters. Let
$$ y_{p}=u_{1}y_{1}+u_{2}y_{2} $$
Where \begin{align*} u_{1} & =-\int\frac{y_{2}f\left( x\right) }{W}dx\\ u_{2} & =\int\frac{y_{1}f\left( x\right) }{W}dx \end{align*}
Where Wronskian is
$$ W= \begin{vmatrix} y_{1} & y_{2}\\ y_{1}^{\prime} & y_{2}^{\prime} \end{vmatrix} = \begin{vmatrix} \cos\left( \sqrt{a}x\right) & \sin\left( \sqrt{a}x\right) \\ -\sqrt{a}\sin\left( \sqrt{a}x\right) & \sqrt{a}\cos\left( \sqrt {a}x\right) \end{vmatrix} =\sqrt{a}\cos^{2}\left( \sqrt{a}x\right) +\sqrt{a}\sin^{2}\left( \sqrt {a}x\right) =\sqrt{a} $$ Hence $$ u_{1}=-\int\frac{\sin\left( \sqrt{a}x\right) f\left( x\right) }{\sqrt{a} }dx=-\frac{1}{\sqrt{a}}\int_{0}^{x}\sin\left( \sqrt{a}t\right) f\left( t\right) dt $$
And
$$ u_{2}=\int\frac{\cos\left( \sqrt{a}x\right) f\left( x\right) }{\sqrt{a} }dx=\frac{1}{\sqrt{a}}\int_{0}^{x}\cos\left( \sqrt{a}t\right) f\left( t\right) dt $$
Therefore
\begin{align*} y & =c_{1}y_{1}+c_{2}y_{2}+u_{1}y_{1}+u_{2}y_{2}\\ & =c_{1}\cos\left( \sqrt{a}x\right) +c_{2}\sin\left( \sqrt{a}x\right) -\left( \frac{1}{\sqrt{a}}\int_{0}^{x}\sin\left( \sqrt{a}t\right) f\left( t\right) dt\right) \cos\left( \sqrt{a}x\right) +\left( \frac{1}{\sqrt{a} }\int_{0}^{x}\cos\left( \sqrt{a}t\right) f\left( t\right) dt\right) \sin\left( \sqrt{a}x\right) \end{align*}
At $x=0$ the above becomes.
$$ 0=c_{1} $$
The solution becomes
$$ y=c_{2}\sin\left( \sqrt{a}x\right) +\frac{1}{\sqrt{a}}\left( \sin\left( \sqrt{a}x\right) \int_{0}^{x}\cos\left( \sqrt{a}t\right) f\left( t\right) dt-\cos\left( \sqrt{a}x\right) \int_{0}^{x}\sin\left( \sqrt{a}t\right) f\left( t\right) dt\right) $$
Taking derivative gives
\begin{equation} y^{\prime}=c_{2}\sqrt{a}\cos\left( \sqrt{a}x\right) +\frac{1}{\sqrt{a} }\left( \frac{d}{dx}\sin\left( \sqrt{a}x\right) \int_{0}^{x}\cos\left( \sqrt{a}t\right) f\left( t\right) dt-\frac{d}{dx}\cos\left( \sqrt {a}x\right) \int_{0}^{x}\sin\left( \sqrt{a}t\right) f\left( t\right) dt\right) \tag{2} \end{equation}
But \begin{align*} \frac{d}{dx}\int_{0}^{x}\cos\left( \sqrt{a}t\right) f\left( t\right) dt & =\cos\left( \sqrt{a}x\right) f\left( x\right) \\ \frac{d}{dx}\int_{0}^{x}\sin\left( \sqrt{a}t\right) f\left( t\right) dt & =\sin\left( \sqrt{a}x\right) f\left( x\right) \end{align*}
Hence (2) becomes
\begin{align*} y^{\prime} & =c_{2}\sqrt{a}\cos\left( \sqrt{a}x\right) \\ & +\frac{1}{\sqrt{a}}\left( \sqrt{a}\cos\left( \sqrt{a}x\right) \int _{0}^{x}\cos\left( \sqrt{a}t\right) f\left( t\right) dt+\sin\left( \sqrt{a}x\right) \cos\left( \sqrt{a}x\right) f\left( x\right) +\sqrt {a}\sin\left( \sqrt{a}x\right) \int_{0}^{x}\sin\left( \sqrt{a}t\right) f\left( t\right) dt+\cos\left( \sqrt{a}x\right) \sin\left( \sqrt {a}x\right) f\left( x\right) \right) \end{align*}
At $x=0$ the above gives
$$ 0=c_{2}\sqrt{a} $$
Hence $c_{2}=0$. Therefore the solution is
\begin{align*} y & =\frac{1}{\sqrt{a}}\left( \sin\left( \sqrt{a}x\right) \int_{0}^{x} \cos\left( \sqrt{a}t\right) f\left( t\right) dt-\cos\left( \sqrt {a}x\right) \int_{0}^{x}\sin\left( \sqrt{a}t\right) f\left( t\right) dt\right) \\ & =\frac{1}{\sqrt{a}}\int_{0}^{x}\left[ \sin\left( \sqrt{a}x\right) \cos\left( \sqrt{a}t\right) f\left( t\right) -\cos\left( \sqrt {a}x\right) \sin\left( \sqrt{a}t\right) f\left( t\right) \right] dt\\ & =\frac{1}{\sqrt{a}}\int_{0}^{x}f\left( t\right) \left[ \sin\left( \sqrt{a}x\right) \cos\left( \sqrt{a}t\right) -\cos\left( \sqrt{a}x\right) \sin\left( \sqrt{a}t\right) \right] dt \end{align*}
Using $$ \sin A\cos B-\cos A\sin B=\sin\left( A-B\right) $$
Then
\begin{align*} y & =\frac{1}{\sqrt{a}}\int_{0}^{x}f\left( t\right) \sin\left( \sqrt {a}x-\sqrt{a}t\right) dt\\ & =\frac{1}{\sqrt{a}}\int_{0}^{x}f\left( t\right) \sin\left( \sqrt {a}\left( x-t\right) \right) dt \end{align*}
ps. One can jump to $y_p$ directly in this problem, since we know that if all initial condition are zero, then $y_h$ will be zero, which means $c_1,c_2$ must be zero and the solution is made up only of $y_p$.