23.3.160 problem 162

Internal problem ID [5874]
Book : Ordinary differential equations and their solutions. By George Moseley Murphy. 1960
Section : Part II. Chapter 3. THE DIFFERENTIAL EQUATION IS LINEAR AND OF SECOND ORDER, page 311
Problem number : 162
Date solved : Friday, October 03, 2025 at 01:44:56 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} -y+2 \tan \left (x \right ) y^{\prime }+y^{\prime \prime }&=\left (1+x \right ) \sec \left (x \right ) \end{align*}
Maple. Time used: 0.110 (sec). Leaf size: 92
ode:=-y(x)+2*tan(x)*diff(y(x),x)+diff(diff(y(x),x),x) = (1+x)*sec(x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \int \left (i \ln \left (\sin \left (x \right )+i \cos \left (x \right )\right ) \tan \left (x \right )+1\right ) \left (1+x \right ) \sec \left (x \right )^{2}d x \sin \left (x \right )+\frac {\left (\left (i \tan \left (x \right )+2 c_1 \right ) \sin \left (x \right )-i \left (1+x \right ) \tan \left (x \right ) \sec \left (x \right )\right ) \ln \left (\sin \left (x \right )+i \cos \left (x \right )\right )}{2}+\frac {\sin \left (x \right ) \left (2 c_2 +1\right )}{2}+\frac {\left (-1-x \right ) \sec \left (x \right )}{2}-i \cos \left (x \right ) c_1 \]
Mathematica. Time used: 0.831 (sec). Leaf size: 69
ode=-y[x] + 2*Tan[x]*D[y[x],x] + D[y[x],{x,2}] == (1 + x)*Sec[x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to \frac {1}{2} \left (\cos (x) (-\arccos (\cos (x)))+\sqrt {\sin ^2(x)}-\cos (x)\right )+c_2 \left (\cos (x)-\sqrt {\sin ^2(x)} \arctan \left (\frac {\cos (x)}{\sqrt {\sin ^2(x)}}\right )\right )+c_1 \sqrt {\sin ^2(x)} \end{align*}
Sympy
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-(x + 1)/cos(x) - y(x) + 2*tan(x)*Derivative(y(x), x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
NotImplementedError : The given ODE -(x + (y(x) - Derivative(y(x), (x, 2)))*cos(x) + 1)/(2*cos(x)*ta