54.1.4 problem 4

Internal problem ID [8532]
Book : Elementary differential equations. Rainville, Bedient, Bedient. Prentice Hall. NJ. 8th edition. 1997.
Section : CHAPTER 8. Nonhomogeneous Equations: Undetermined Coefficients. Exercises Page 142
Problem number : 4
Date solved : Wednesday, March 05, 2025 at 06:02:48 AM
CAS classification : [[_2nd_order, _with_linear_symmetries]]

\begin{align*} y^{\prime \prime }+3 y^{\prime }+2 y&=x^{2}+2 x +1 \end{align*}

Maple. Time used: 0.002 (sec). Leaf size: 27
ode:=diff(diff(y(x),x),x)+3*diff(y(x),x)+2*y(x) = x^2+2*x+1; 
dsolve(ode,y(x), singsol=all);
 
\[ y = \frac {3}{4}+\frac {x^{2}}{2}-\frac {x}{2}-c_{1} {\mathrm e}^{-2 x}+c_{2} {\mathrm e}^{-x} \]
Mathematica. Time used: 0.024 (sec). Leaf size: 36
ode=D[y[x],{x,2}]+3*D[y[x],x]+2*y[x]==1+2*x+x^2; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \frac {1}{4} \left (2 x^2-2 x+3\right )+c_1 e^{-2 x}+c_2 e^{-x} \]
Sympy. Time used: 0.210 (sec). Leaf size: 26
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x**2 - 2*x + 2*y(x) + 3*Derivative(y(x), x) + Derivative(y(x), (x, 2)) - 1,0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = C_{1} e^{- 2 x} + C_{2} e^{- x} + \frac {x^{2}}{2} - \frac {x}{2} + \frac {3}{4} \]