23.2.16 problem 6(e)

Internal problem ID [4133]
Book : Theory and solutions of Ordinary Differential equations, Donald Greenspan, 1960
Section : Chapter 3. Linear differential equations of second order. Exercises at page 31
Problem number : 6(e)
Date solved : Sunday, March 30, 2025 at 02:40:39 AM
CAS classification : [[_2nd_order, _with_linear_symmetries]]

\begin{align*} y^{\prime \prime }+2 y&=x +{\mathrm e}^{2 x} \end{align*}

Maple. Time used: 0.002 (sec). Leaf size: 30
ode:=diff(diff(y(x),x),x)+2*y(x) = x+exp(2*x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \sin \left (\sqrt {2}\, x \right ) c_2 +\cos \left (\sqrt {2}\, x \right ) c_1 +\frac {x}{2}+\frac {{\mathrm e}^{2 x}}{6} \]
Mathematica. Time used: 0.277 (sec). Leaf size: 42
ode=D[y[x],{x,2}]+2*y[x]==x+Exp[2*x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \frac {1}{6} \left (3 x+e^{2 x}+6 c_1 \cos \left (\sqrt {2} x\right )+6 c_2 \sin \left (\sqrt {2} x\right )\right ) \]
Sympy. Time used: 0.079 (sec). Leaf size: 32
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x + 2*y(x) - exp(2*x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = C_{1} \sin {\left (\sqrt {2} x \right )} + C_{2} \cos {\left (\sqrt {2} x \right )} + \frac {x}{2} + \frac {e^{2 x}}{6} \]