69.18.22 problem 611

Internal problem ID [18397]
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. Initial value problem. Exercises page 140
Problem number : 611
Date solved : Thursday, October 02, 2025 at 03:11:22 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }-y&=-2 \cos \left (x \right ) \end{align*}
Maple. Time used: 0.004 (sec). Leaf size: 17
ode:=diff(diff(y(x),x),x)-y(x) = -2*cos(x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = {\mathrm e}^{-x} c_2 +{\mathrm e}^{x} c_1 +\cos \left (x \right ) \]
Mathematica. Time used: 0.009 (sec). Leaf size: 22
ode=D[y[x],{x,2}]-y[x]==-2*Cos[x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to \cos (x)+c_1 e^x+c_2 e^{-x} \end{align*}
Sympy. Time used: 0.034 (sec). Leaf size: 15
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-y(x) + 2*cos(x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = C_{1} e^{- x} + C_{2} e^{x} + \cos {\left (x \right )} \]