23.3.14 problem 8(d)

Internal problem ID [4155]
Book : Theory and solutions of Ordinary Differential equations, Donald Greenspan, 1960
Section : Chapter 4. The general linear differential equation of order n. Exercises at page 63
Problem number : 8(d)
Date solved : Tuesday, March 04, 2025 at 05:54:24 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+3 y^{\prime }+2 y&={\mathrm e}^{x}-2 \,{\mathrm e}^{2 x}+\sin \left (x \right ) \end{align*}

Maple. Time used: 0.003 (sec). Leaf size: 44
ode:=diff(diff(y(x),x),x)+3*diff(y(x),x)+2*y(x) = exp(x)-2*exp(2*x)+sin(x); 
dsolve(ode,y(x), singsol=all);
 
\[ y \left (x \right ) = -\frac {\left (\frac {3 \left (3 \cos \left (x \right )-\sin \left (x \right )\right ) {\mathrm e}^{2 x}}{5}-6 c_{2} {\mathrm e}^{x}+{\mathrm e}^{4 x}+6 c_{1} -{\mathrm e}^{3 x}\right ) {\mathrm e}^{-2 x}}{6} \]
Mathematica. Time used: 0.313 (sec). Leaf size: 45
ode=D[y[x],{x,2}]+3*D[y[x],x]+2*y[x]==Exp[x]-2*Exp[2*x]+Sin[x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to c_1 e^{-2 x}+c_2 e^{-x}+\frac {1}{30} \left (-5 e^x \left (e^x-1\right )+3 \sin (x)-9 \cos (x)\right ) \]
Sympy. Time used: 0.272 (sec). Leaf size: 37
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(2*y(x) + 2*exp(2*x) - exp(x) - sin(x) + 3*Derivative(y(x), x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = C_{1} e^{- 2 x} + C_{2} e^{- x} - \frac {e^{2 x}}{6} + \frac {e^{x}}{6} + \frac {\sin {\left (x \right )}}{10} - \frac {3 \cos {\left (x \right )}}{10} \]