83.17.6 problem 6

Internal problem ID [19131]
Book : A Text book for differentional equations for postgraduate students by Ray and Chaturvedi. First edition, 1958. BHASKAR press. INDIA
Section : Chapter III. Ordinary linear differential equations with constant coefficients. Misc. Examples on chapter III at page 50
Problem number : 6
Date solved : Monday, March 31, 2025 at 06:49:14 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

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