42.1.11 problem Example 3.11

Internal problem ID [8798]
Book : THEORY OF DIFFERENTIAL EQUATIONS IN ENGINEERING AND MECHANICS. K.T. CHAU, CRC Press. Boca Raton, FL. 2018
Section : Chapter 3. Ordinary Differential Equations. Section 3.2 FIRST ORDER ODE. Page 114
Problem number : Example 3.11
Date solved : Tuesday, September 30, 2025 at 05:51:37 PM
CAS classification : [_separable]

\begin{align*} y^{\prime }&=-\frac {2}{t}+\frac {y}{t}+\frac {y^{2}}{t} \end{align*}
Maple. Time used: 0.129 (sec). Leaf size: 22
ode:=diff(y(t),t) = -2/t+y(t)/t+1/t*y(t)^2; 
dsolve(ode,y(t), singsol=all);
 
\[ y = \frac {-2 t^{3} c_1 -1}{t^{3} c_1 -1} \]
Mathematica. Time used: 0.757 (sec). Leaf size: 43
ode=D[y[t],t]==-2/t+1/t*y[t]+1/t*y[t]^2; 
ic={}; 
DSolve[{ode,ic},y[t],t,IncludeSingularSolutions->True]
 
\begin{align*} y(t)&\to \frac {1-2 e^{3 c_1} t^3}{1+e^{3 c_1} t^3}\\ y(t)&\to -2\\ y(t)&\to 1 \end{align*}
Sympy. Time used: 0.208 (sec). Leaf size: 26
from sympy import * 
t = symbols("t") 
y = Function("y") 
ode = Eq(Derivative(y(t), t) - y(t)**2/t - y(t)/t + 2/t,0) 
ics = {} 
dsolve(ode,func=y(t),ics=ics)
 
\[ y{\left (t \right )} = \frac {- 2 t^{3} e^{3 C_{1}} - 1}{t^{3} e^{3 C_{1}} - 1} \]