15.15.3 problem 3

Internal problem ID [3207]
Book : Differential Equations by Alfred L. Nelson, Karl W. Folley, Max Coral. 3rd ed. DC heath. Boston. 1964
Section : Exercise 24, page 109
Problem number : 3
Date solved : Sunday, March 30, 2025 at 01:21:13 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

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