69.16.57 problem 530

Internal problem ID [18317]
Book : A book of problems in ordinary differential equations. M.L. KRASNOV, A.L. KISELYOV, G.I. MARKARENKO. MIR, MOSCOW. 1983
Section : Chapter 2 (Higher order ODEs). Section 15.3 Nonhomogeneous linear equations with constant coefficients. Trial and error method. Exercises page 132
Problem number : 530
Date solved : Thursday, October 02, 2025 at 03:10:23 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }-2 m y^{\prime }+m^{2} y&=\sin \left (n x \right ) \end{align*}
Maple. Time used: 0.004 (sec). Leaf size: 56
ode:=diff(diff(y(x),x),x)-2*m*diff(y(x),x)+m^2*y(x) = sin(n*x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \frac {\left (m^{2}+n^{2}\right )^{2} \left (c_1 x +c_2 \right ) {\mathrm e}^{m x}+\left (m^{2}-n^{2}\right ) \sin \left (n x \right )+2 \cos \left (n x \right ) m n}{\left (m^{2}+n^{2}\right )^{2}} \]
Mathematica. Time used: 0.067 (sec). Leaf size: 63
ode=D[y[x],{x,2}]-2*m*D[y[x],x]+m^2*y[x]==Sin[n*x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to e^{m x} \left (\int _1^x-e^{-m K[1]} K[1] \sin (n K[1])dK[1]+x \int _1^xe^{-m K[2]} \sin (n K[2])dK[2]+c_2 x+c_1\right ) \end{align*}
Sympy. Time used: 0.195 (sec). Leaf size: 85
from sympy import * 
x = symbols("x") 
m = symbols("m") 
n = symbols("n") 
y = Function("y") 
ode = Eq(m**2*y(x) - 2*m*Derivative(y(x), x) - sin(n*x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \frac {m^{2} \sin {\left (n x \right )}}{m^{4} + 2 m^{2} n^{2} + n^{4}} + \frac {2 m n \cos {\left (n x \right )}}{m^{4} + 2 m^{2} n^{2} + n^{4}} - \frac {n^{2} \sin {\left (n x \right )}}{m^{4} + 2 m^{2} n^{2} + n^{4}} + \left (C_{1} + C_{2} x\right ) e^{m x} \]