9
$\begingroup$

This question already has an answer here:

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?

$\endgroup$

marked as duplicate by xzczd, Carl Woll, halirutan, MarcoB, Michael E2 differential-equations Jun 2 '18 at 18:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

9
$\begingroup$

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[1] - Log[x]}*)
$\endgroup$
  • $\begingroup$ Nice idea (+1). $\endgroup$ – Carl Woll Jun 2 '18 at 5:50
4
$\begingroup$

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] *)
$\endgroup$

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