Problem 220
Medium Trajectories

Solve the differential equation (xy-x^2)y'+y^2-3xy-2x^2=0

Solve the differential equation $(xy-x^2)y'+y^2-3xy-2x^2=0$.

Explanation of Method

Confirm the equation is homogeneous, reduce it with $y=vx$ to a separable equation in $v(x)$, integrate using \texttt{sympy.integrate} (verifying the source's derivative-matching trick for $\int(v-1)/(v^2-2v-1)\,dv$ independently), back-substitute, and confirm the final implicit solution by implicit differentiation with \texttt{sympy} against the original equation.

Step 1: Homogeneous reduction with $y=vx$, checked by \texttt{sympy}

Substituting $y=vx$ into $\dfrac{dy}{dx}=\dfrac{3xy+2x^2-y^2}{x(y-x)}$ and calling \texttt{sympy.simplify}, the right side reduces to $\dfrac{-v^2+3v+2}{v-1}$ (all $x^2$ factors cancel, confirming homogeneity), matching the source. Then \[x\frac{dv}{dx}=\frac{-v^2+3v+2}{v-1}-v=\frac{-2v^2+4v+2}{v-1}=\frac{-2(v^2-2v-1)}{v-1},\] also confirmed by \texttt{sympy.simplify}, matching the source exactly.

Step 2: Separate and integrate, verifying the derivative-matching trick independently

Separating: $\dfrac{v-1}{v^2-2v-1}\,dv=-\dfrac{2\,dx}{x}$. \texttt{sympy} confirms $\dfrac{d}{dv}(v^2-2v-1)=2v-2=2(v-1)$, so the left integrand is exactly half the logarithmic-derivative form. Calling \texttt{sympy.integrate((v-1)/(v**2-2*v-1), v)} independently returns \[\int\frac{v-1}{v^2-2v-1}\,dv=\tfrac12\ln|v^2-2v-1|+C_1,\] confirming the source's trick exactly. Integrating the right side and combining constants gives \[v^2-2v-1=\frac{C}{x^4}.\]

Step 3: Back-substitute $v=y/x$

\[\frac{y^2}{x^2}-\frac{2y}{x}-1=\frac{C}{x^4}\ \Longrightarrow\ x^2y^2-2x^3y-x^4=C.\]

Step 4: Full independent verification via implicit differentiation

Using \texttt{sympy.Function('y')(x)}, implicitly differentiating $x^2y^2-2x^3y-x^4=C$, solving for $y'$, and substituting into $(xy-x^2)y'+y^2-3xy-2x^2$, \texttt{sympy.simplify} on the result returns exactly $0$ — a full symbolic confirmation, matching the source's own by-hand verification.


Result

Final answer:

The source's derivation is confirmed correct at every step (the homogeneity check, the integration via the derivative-matching trick, and the final implicit-differentiation verification): \[\boxed{\,x^2y^2-2x^3y-x^4=C\,}\] where $C$ is an arbitrary constant.