Problem 216
Medium Trajectories

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

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

Explanation of Method

Rewrite the equation with $x$ as the dependent variable (since it is linear in $x^2$ that way), substitute $v=x^2$ to reduce it to a first-order linear equation in $v(y)$, solve via integrating factor with \texttt{sympy.integrate} handling the integration by parts independently, and verify the final implicit solution by differentiating it and recovering the original equation exactly.

Step 1: Reverse the roles of $x$ and $y$

From $(y-x^2)\,dy/dx=x$ we get $dx/dy=(y-x^2)/x=y/x-x$. Multiplying by $x$ and setting $v=x^2$ (so $dv/dy=2x\,dx/dy$, i.e. $x\,dx/dy=\tfrac12\,dv/dy$) turns this into \[\frac{dv}{dy}+2v=2y,\] a first-order linear equation in $v(y)$ — matching the source's reduction exactly.

Step 2: Solve the linear equation, verifying the integration by parts with \texttt{sympy}

The integrating factor is $\mu(y)=e^{2y}$, giving $\dfrac{d}{dy}(ve^{2y})=2ye^{2y}$. Calling \texttt{sympy.integrate(2*y*sp.exp(2*y), y)} independently (not trusting the source's by-hand integration by parts) returns \[\int 2ye^{2y}\,dy=\left(y-\tfrac12\right)e^{2y}+C,\] confirming the source's result exactly. Hence \[v=y-\frac12+Ce^{-2y}.\]

Step 3: Back-substitute

Recall $v=x^2$: \[x^2=y-\frac12+Ce^{-2y}.\]

Step 4: Independent full verification via implicit differentiation

Treating $x$ as a function of $y$ (\texttt{sympy.Function('X')(y)}), differentiating $X^2=y-\tfrac12+Ce^{-2y}$ implicitly in $y$ and eliminating $C$ using the original relation gives, after \texttt{sympy.simplify}, exactly $dX/dy=y/X-X=(y-X^2)/X$ — reproducing equation (3) with zero residual. Separately, treating $y$ as a function of $x$ and differentiating the relation implicitly in $x$, eliminating $C$ the same way, gives $dy/dx=-x/(x^2-y)$; substituting into the original equation $(y-x^2)y'-x$ and calling \texttt{sympy.simplify} on the result returns exactly $0$. Both directions confirm the solution independently.


Result

Final answer:

The source's derivation is confirmed correct end-to-end by independent \texttt{sympy} computation (the integration by parts, and both directions of the implicit-differentiation check): \[\boxed{\,x^2=y-\frac12+Ce^{-2y}\,}\] where $C$ is an arbitrary constant, giving the solution implicitly.