47.2.31 problem Example 3

Internal problem ID [7447]
Book : Ordinary differential equations and calculus of variations. Makarets and Reshetnyak. Wold Scientific. Singapore. 1995
Section : Chapter 1. First order differential equations. Section 1.2 Homogeneous equations problems. page 12
Problem number : Example 3
Date solved : Sunday, March 30, 2025 at 12:07:05 PM
CAS classification : [[_homogeneous, `class C`], _rational, [_Abel, `2nd type`, `class A`]]

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

Maple. Time used: 0.185 (sec). Leaf size: 30
ode:=diff(y(x),x) = (x+y(x)-2)/(y(x)-x-4); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \frac {-\sqrt {2 \left (x +1\right )^{2} c_1^{2}+1}+\left (x +4\right ) c_1}{c_1} \]
Mathematica. Time used: 0.136 (sec). Leaf size: 59
ode=D[y[x],x]==(x+y[x]-2)/(y[x]-x-4); 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)\to -i \sqrt {-2 x^2-4 x-16-c_1}+x+4 \\ y(x)\to i \sqrt {-2 x^2-4 x-16-c_1}+x+4 \\ \end{align*}
Sympy. Time used: 1.952 (sec). Leaf size: 37
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(Derivative(y(x), x) - (x + y(x) - 2)/(-x + y(x) - 4),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ \left [ y{\left (x \right )} = x - \sqrt {C_{1} + 2 x^{2} + 4 x} + 4, \ y{\left (x \right )} = x + \sqrt {C_{1} + 2 x^{2} + 4 x} + 4\right ] \]