63.1.115 problem 163

Internal problem ID [15555]
Book : DIFFERENTIAL and INTEGRAL CALCULUS. VOL I. by N. PISKUNOV. MIR PUBLISHERS, Moscow 1969.
Section : Chapter 8. Differential equations. Exercises page 595
Problem number : 163
Date solved : Thursday, October 02, 2025 at 10:19:50 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

With initial conditions

\begin{align*} y \left (0\right )&=a \\ y^{\prime }\left (0\right )&=c \\ \end{align*}
Maple. Time used: 0.048 (sec). Leaf size: 61
ode:=diff(diff(y(x),x),x)+n^2*y(x) = h*sin(r*x); 
ic:=[y(0) = a, D(y)(0) = c]; 
dsolve([ode,op(ic)],y(x), singsol=all);
 
\[ y = -\frac {\left (-c \,n^{2}+c \,r^{2}+h r \right ) \sin \left (n x \right )}{n^{3}-n \,r^{2}}+\cos \left (n x \right ) a +\frac {h \sin \left (r x \right )}{n^{2}-r^{2}} \]
Mathematica. Time used: 0.019 (sec). Leaf size: 63
ode=D[y[x],{x,2}]+n^2*y[x]==h*Sin[r*x]; 
ic={y[0]==a,Derivative[1][y][0] ==c}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to \frac {a n \left (n^2-r^2\right ) \cos (n x)+\sin (n x) \left (c n^2-c r^2-h r\right )+h n \sin (r x)}{n^3-n r^2} \end{align*}
Sympy. Time used: 0.106 (sec). Leaf size: 114
from sympy import * 
x = symbols("x") 
h = symbols("h") 
n = symbols("n") 
r = symbols("r") 
y = Function("y") 
ode = Eq(-h*sin(r*x) + n**2*y(x) + Derivative(y(x), (x, 2)),0) 
ics = {y(0): a, Subs(Derivative(y(x), x), x, 0): c} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = - \frac {h \sin {\left (r x \right )}}{- n^{2} + r^{2}} + \frac {\left (- a n^{3} + a n r^{2} - i c n^{2} + i c r^{2} + i h r\right ) e^{- i n x}}{- 2 n^{3} + 2 n r^{2}} + \frac {\left (- a n^{3} + a n r^{2} + i c n^{2} - i c r^{2} - i h r\right ) e^{i n x}}{- 2 n^{3} + 2 n r^{2}} \]