60.3.3 problem 1003

Internal problem ID [10999]
Book : Differential Gleichungen, E. Kamke, 3rd ed. Chelsea Pub. NY, 1948
Section : Chapter 2, linear second order
Problem number : 1003
Date solved : Wednesday, March 05, 2025 at 01:36:57 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

Maple. Time used: 0.003 (sec). Leaf size: 26
ode:=diff(diff(y(x),x),x)+y(x)-sin(n*x) = 0; 
dsolve(ode,y(x), singsol=all);
 
\[ y = \sin \left (x \right ) c_{2} +\cos \left (x \right ) c_{1} -\frac {\sin \left (n x \right )}{n^{2}-1} \]
Mathematica. Time used: 0.199 (sec). Leaf size: 55
ode=-Sin[n*x] + y[x] + D[y[x],{x,2}] == 0; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \cos (x) \int _1^x-\sin (K[1]) \sin (n K[1])dK[1]+\sin (x) \int _1^x\cos (K[2]) \sin (n K[2])dK[2]+c_1 \cos (x)+c_2 \sin (x) \]
Sympy. Time used: 0.081 (sec). Leaf size: 22
from sympy import * 
x = symbols("x") 
n = symbols("n") 
y = Function("y") 
ode = Eq(y(x) - sin(n*x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = C_{1} \sin {\left (x \right )} + C_{2} \cos {\left (x \right )} - \frac {\sin {\left (n x \right )}}{n^{2} - 1} \]