40.10.8 problem 17

Internal problem ID [6730]
Book : Schaums Outline. Theory and problems of Differential Equations, 1st edition. Frank Ayres. McGraw Hill 1952
Section : Chapter 15. Linear equations with constant coefficients (Variation of parameters). Supplemetary problems. Page 98
Problem number : 17
Date solved : Sunday, March 30, 2025 at 11:20:51 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

Maple. Time used: 0.002 (sec). Leaf size: 38
ode:=diff(diff(y(x),x),x)+2*diff(y(x),x)+2*y(x) = x^2+sin(x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = {\mathrm e}^{-x} \sin \left (x \right ) c_2 +{\mathrm e}^{-x} \cos \left (x \right ) c_1 +\frac {x^{2}}{2}-x +\frac {1}{2}-\frac {2 \cos \left (x \right )}{5}+\frac {\sin \left (x \right )}{5} \]
Mathematica. Time used: 0.282 (sec). Leaf size: 50
ode=D[y[x],{x,2}]+2*D[y[x],x]+2*y[x]==x^2+Sin[x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \frac {1}{10} e^{-x} \left (5 e^x (x-1)^2+\left (-4 e^x+10 c_2\right ) \cos (x)+2 \left (e^x+5 c_1\right ) \sin (x)\right ) \]
Sympy. Time used: 0.340 (sec). Leaf size: 37
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x**2 + 2*y(x) - sin(x) + 2*Derivative(y(x), x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \frac {x^{2}}{2} - x + \left (C_{1} \sin {\left (x \right )} + C_{2} \cos {\left (x \right )}\right ) e^{- x} + \frac {\sin {\left (x \right )}}{5} - \frac {2 \cos {\left (x \right )}}{5} + \frac {1}{2} \]