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?
Answer
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]}*)
Comments
Post a Comment