72.13.12 problem 2

Internal problem ID [19620]
Book : DIFFERENTIAL EQUATIONS WITH APPLICATIONS AND HISTORICAL NOTES by George F. Simmons. 3rd edition. 2017. CRC press, Boca Raton FL.
Section : Chapter 3. Second order linear equations. Section 18. The Method of Undetermined Coefficients. Problems at page 132
Problem number : 2
Date solved : Thursday, October 02, 2025 at 04:40:43 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+k^{2} y&=\sin \left (b x \right ) \end{align*}
Maple. Time used: 0.005 (sec). Leaf size: 34
ode:=diff(diff(y(x),x),x)+k^2*y(x) = sin(b*x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \sin \left (k x \right ) c_2 +\cos \left (k x \right ) c_1 -\frac {\sin \left (b x \right )}{b^{2}-k^{2}} \]
Mathematica. Time used: 0.176 (sec). Leaf size: 56
ode=D[y[x],{x,2}] +k^2*y[x]==Sin[b*x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to \frac {-\left (c_1 \left (b^2-k^2\right ) \cos (k x)\right )+c_2 \left (k^2-b^2\right ) \sin (k x)+\sin (b x)}{(k-b) (b+k)} \end{align*}
Sympy. Time used: 0.064 (sec). Leaf size: 31
from sympy import * 
x = symbols("x") 
b = symbols("b") 
k = symbols("k") 
y = Function("y") 
ode = Eq(k**2*y(x) - sin(b*x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = C_{1} e^{- i k x} + C_{2} e^{i k x} - \frac {\sin {\left (b x \right )}}{b^{2} - k^{2}} \]