85.56.5 problem 1 (e)

Internal problem ID [22830]
Book : Applied Differential Equations. By Murray R. Spiegel. 3rd edition. 1980. Pearson. ISBN 978-0130400970
Section : Chapter 4. Linear differential equations. A Exercises at page 199
Problem number : 1 (e)
Date solved : Thursday, October 02, 2025 at 09:15:29 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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