75.16.15 problem 488

Internal problem ID [16917]
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 : 488
Date solved : Monday, March 31, 2025 at 03:35:28 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+k^{2} y&=k \sin \left (k x +\alpha \right ) \end{align*}

Maple. Time used: 0.005 (sec). Leaf size: 39
ode:=diff(diff(y(x),x),x)+k^2*y(x) = k*sin(k*x+alpha); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \sin \left (k x \right ) c_2 +\cos \left (k x \right ) c_1 +\frac {-2 k x \cos \left (k x +\alpha \right )+\sin \left (k x +\alpha \right )}{4 k} \]
Mathematica. Time used: 0.136 (sec). Leaf size: 71
ode=D[y[x],{x,2}]+k^2*y[x]==k*Sin[k*x+\[Alpha]]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \cos (k x) \int _1^x-\sin (k K[1]) \sin (\alpha +k K[1])dK[1]+\sin (k x) \int _1^x\cos (k K[2]) \sin (\alpha +k K[2])dK[2]+c_1 \cos (k x)+c_2 \sin (k x) \]
Sympy. Time used: 0.134 (sec). Leaf size: 29
from sympy import * 
x = symbols("x") 
Alpha = symbols("Alpha") 
k = symbols("k") 
y = Function("y") 
ode = Eq(k**2*y(x) - k*sin(Alpha + k*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 {x \cos {\left (\mathrm {A} + k x \right )}}{2} \]