82.33.4 problem Ex. 4

Internal problem ID [18818]
Book : Introductory Course On Differential Equations by Daniel A Murray. Longmans Green and Co. NY. 1924
Section : Chapter VI. Linear equations with constant coefficients. Examples on chapter VI, page 80
Problem number : Ex. 4
Date solved : Thursday, March 13, 2025 at 12:59:53 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

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