64.11.22 problem 22

Internal problem ID [13401]
Book : Differential Equations by Shepley L. Ross. Third edition. John Willey. New Delhi. 2004.
Section : Chapter 4, Section 4.3. The method of undetermined coefficients. Exercises page 151
Problem number : 22
Date solved : Monday, March 31, 2025 at 07:53:15 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

Maple. Time used: 0.003 (sec). Leaf size: 37
ode:=diff(diff(y(x),x),x)+4*y(x) = 12*x^2-16*x*cos(2*x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = -\frac {3}{2}+\frac {\left (-8 x^{2}+4 c_2 +1\right ) \sin \left (2 x \right )}{4}+\left (-x +c_1 \right ) \cos \left (2 x \right )+3 x^{2} \]
Mathematica. Time used: 0.927 (sec). Leaf size: 86
ode=D[y[x],{x,2}]+4*y[x]==12*x^2-16*x*Cos[2*x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \cos (2 x) \int _1^x2 (4 \cos (2 K[1])-3 K[1]) K[1] \sin (2 K[1])dK[1]+\sin (2 x) \int _1^x2 \cos (2 K[2]) K[2] (3 K[2]-4 \cos (2 K[2]))dK[2]+c_1 \cos (2 x)+c_2 \sin (2 x) \]
Sympy. Time used: 0.155 (sec). Leaf size: 31
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-12*x**2 + 16*x*cos(2*x) + 4*y(x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = 3 x^{2} + \left (C_{1} - x\right ) \cos {\left (2 x \right )} + \left (C_{2} - 2 x^{2}\right ) \sin {\left (2 x \right )} - \frac {3}{2} \]