75.18.14 problem 603

Internal problem ID [17031]
Book : A book of problems in ordinary differential equations. M.L. KRASNOV, A.L. KISELYOV, G.I. MARKARENKO. MIR, MOSCOW. 1983
Section : Chapter 2 (Higher order ODEs). Section 15.3 Nonhomogeneous linear equations with constant coefficients. Initial value problem. Exercises page 140
Problem number : 603
Date solved : Monday, March 31, 2025 at 03:38:41 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

With initial conditions

\begin{align*} y \left (\pi \right )&=\pi \,{\mathrm e}^{\pi }\\ y^{\prime }\left (\pi \right )&={\mathrm e}^{\pi } \end{align*}

Maple. Time used: 0.031 (sec). Leaf size: 25
ode:=diff(diff(y(x),x),x)-2*diff(y(x),x)+2*y(x) = 4*exp(x)*cos(x); 
ic:=y(Pi) = Pi*exp(Pi), D(y)(Pi) = exp(Pi); 
dsolve([ode,ic],y(x), singsol=all);
 
\[ y = {\mathrm e}^{x} \left (2 x -\pi -1\right ) \sin \left (x \right )-{\mathrm e}^{x} \cos \left (x \right ) \pi \]
Mathematica. Time used: 0.045 (sec). Leaf size: 68
ode=D[y[x],{x,2}]-2*D[y[x],x]+2*y[x]==4*Exp[x]*Cos[x]; 
ic={y[Pi]==Pi*Exp[Pi],Derivative[1][y][Pi]==Exp[Pi]}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to e^x \left (-\sin (x) \int _1^{\pi }4 \cos ^2(K[1])dK[1]+\sin (x) \int _1^x4 \cos ^2(K[1])dK[1]+\pi \sin (x)-\sin (x)+2 \cos ^3(x)-\pi \cos (x)-2 \cos (x)\right ) \]
Sympy. Time used: 0.250 (sec). Leaf size: 20
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(2*y(x) - 4*exp(x)*cos(x) - 2*Derivative(y(x), x) + Derivative(y(x), (x, 2)),0) 
ics = {y(pi): pi*exp(pi), Subs(Derivative(y(x), x), x, pi): exp(pi)} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \left (\left (2 x - \pi - 1\right ) \sin {\left (x \right )} - \pi \cos {\left (x \right )}\right ) e^{x} \]