78.13.13 problem 3 (a)

Internal problem ID [18256]
Book : DIFFERENTIAL EQUATIONS WITH APPLICATIONS AND HISTORICAL NOTES by George F. Simmons. 3rd edition. 2017. CRC press, Boca Raton FL.
Section : Chapter 3. Second order linear equations. Section 18. The Method of Undetermined Coefficients. Problems at page 132
Problem number : 3 (a)
Date solved : Thursday, March 13, 2025 at 11:51:19 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+4 y&=4 \cos \left (2 x \right )+6 \cos \left (x \right )+8 x^{2}-4 x \end{align*}

Maple. Time used: 0.004 (sec). Leaf size: 37
ode:=diff(diff(y(x),x),x)+4*y(x) = 4*cos(2*x)+6*cos(x)+8*x^2-4*x; 
dsolve(ode,y(x), singsol=all);
 
\[ y = -1+\frac {\left (1+4 c_{1} \right ) \cos \left (2 x \right )}{4}+\left (c_{2} +x \right ) \sin \left (2 x \right )+2 x^{2}-x +2 \cos \left (x \right ) \]
Mathematica. Time used: 0.364 (sec). Leaf size: 43
ode=D[y[x],{x,2}] +4*y[x]==4*Cos[2*x]+6*Cos[x]+8*x^2-4*x; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to 2 x^2-x+x \sin (2 x)+2 \cos (x)+\left (\frac {1}{2}+c_1\right ) \cos (2 x)+c_2 \sin (2 x)-1 \]
Sympy. Time used: 0.113 (sec). Leaf size: 31
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-8*x**2 + 4*x + 4*y(x) - 6*cos(x) - 4*cos(2*x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = C_{2} \cos {\left (2 x \right )} + 2 x^{2} - x + \left (C_{1} + x\right ) \sin {\left (2 x \right )} + 2 \cos {\left (x \right )} - 1 \]