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:

enter image description here

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:

enter image description here

So how should I proceed?


2 Answers 2


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?

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

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[1] - Log[x]}*)
  • $\begingroup$ Nice idea (+1). $\endgroup$
    – Carl Woll
    Commented 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[%[[1]] /. 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[1] - Log[x] *)

Not the answer you're looking for? Browse other questions tagged or ask your own question.