8.8.4 problem 24

Internal problem ID [841]
Book : Differential equations and linear algebra, 3rd ed., Edwards and Penney
Section : Section 5.2, second order linear equations. Page 311
Problem number : 24
Date solved : Tuesday, March 04, 2025 at 11:53:21 AM
CAS classification : [[_2nd_order, _with_linear_symmetries]]

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

With initial conditions

\begin{align*} y \left (0\right )&=4\\ y^{\prime }\left (0\right )&=8 \end{align*}

Maple. Time used: 0.005 (sec). Leaf size: 19
ode:=diff(diff(y(x),x),x)-2*diff(y(x),x)+2*y(x) = 2*x; 
ic:=y(0) = 4, D(y)(0) = 8; 
dsolve([ode,ic],y(x), singsol=all);
 
\[ y = x +1+\left (3 \cos \left (x \right )+4 \sin \left (x \right )\right ) {\mathrm e}^{x} \]
Mathematica. Time used: 0.014 (sec). Leaf size: 22
ode=D[y[x],{x,2}]-2*D[y[x],x]+2*y[x]==2*x; 
ic={y[0]==4,Derivative[1][y][0] ==8}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to x+4 e^x \sin (x)+3 e^x \cos (x)+1 \]
Sympy. Time used: 0.176 (sec). Leaf size: 19
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-2*x + 2*y(x) - 2*Derivative(y(x), x) + Derivative(y(x), (x, 2)),0) 
ics = {y(0): 4, Subs(Derivative(y(x), x), x, 0): 8} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = x + \left (4 \sin {\left (x \right )} + 3 \cos {\left (x \right )}\right ) e^{x} + 1 \]