# How to stop DSolve from solving equations [duplicate]

I'm tring to solve this ODE, DSolve[y'[x] == Sqrt[1 + (x/y[x])^2] - x/y[x], y[x], {x}]. Mathematica gives this as the result: I don't want Mathematica to solve the final (implicit) equation. I know that this code

Block[{Integrate = Inactive@Integrate},
DSolve[y'[x] == Sqrt[1 + (x/y[x])^2] - x/y[x], y[x], {x}]]


can stop DSolve from integrating, so I tried this

Block[{Solve = Inactive@Solve},
DSolve[y'[x] == Sqrt[1 + (x/y[x])^2] - x/y[x], y[x], {x}]]


but it didn't work: So how should I proceed?

It seems that Solve will be called during the DSolve calculation, so if you stop Solve, the DSolve doesn't work as well.

To avoid that, we can think in another way. Do not stop Solve, but store the equations whenever Solve is called. The last stored equations is what you need.

Here is a sample code, the usage of Block comes from What are some advanced uses for Block?

Unprotect[Solve];
Solve[args___ /; ! TrueQ[inF]] := Block[{inF = True}, Sow[args]; Solve[args]];
Protect[Solve];

Reap[DSolve[y'[x] == Sqrt[1 + (x/y[x])^2] - x/y[x], y[x], {x}]][[2, -1]]

(*{Log[1 - Sqrt[1 + y[x]^2/x^2]] == C - Log[x]}*)

• Nice idea (+1). Jun 2, 2018 at 5:50

I do not know why the approach taken in the question does not work, because it depends on the inner workings of DSolve. However, this may provide the desired result.

Quiet@Block[{Integrate = Inactive@Integrate},
DSolve[y'[x] == Sqrt[1 + (x/y[x])^2] - x/y[x], y[x], {x}]];
Activate[%[] /. y[x] -> z[x] x] /. z[x] -> y[x]/x

(* -ArcTanh[Sqrt[1 + y[x]^2/x^2]] + 1/2 Log[-(y[x]^2/x^2)] == C - Log[x] *)