2
$\begingroup$

I want to get the general solution of a first-order ODE in implicit form. It should be something like this:

  1. With input y'[x] == 1, the desired output is C[1]->y[x] - x.
  2. With input y'[x] == 1/y[x]^2 (nonlinear ODE), the desired output is C[1]->y[x]^3/3 - x

DSolve tries to evaluate the explicit form of y[x] by default. Is it possible to keep the implicit solution?

I tried explicit equation integration using Integrate and tracing (Trace with TraceInternal -> True). Neither helped me with this problem.

$\endgroup$
  • 1
    $\begingroup$ Strongly related, if not duplicate: mathematica.stackexchange.com/q/137598/1871 $\endgroup$ – xzczd Oct 14 '18 at 12:48
  • $\begingroup$ But this seems not to work correctly. Quiet@Trace[DSolve[y'[x] == 1, y[x], x], Solve[e_, y[x]] -> (eqn = e), TraceInternal -> True]; eqn returns -1 + y[x] == 0 with no integration constant $\endgroup$ – Ilya Oct 14 '18 at 12:54
  • $\begingroup$ Yes, and that's the reason I didn't vote for close as duplicate. $\endgroup$ – xzczd Oct 14 '18 at 13:04
4
$\begingroup$

The following works for the two examples in the OP:

eq = y'[x] == 1; (* try also eq = y'[x] == 1/y[x]^2 *)
Solve[Equal @@ DSolve[eq, y[x], x][[1, 1]], C[1]]
(* C[1] -> -x + y[x] *)

Higher order ODEs contain more constants of integration, so OP shall modify the code accordingly.

$\endgroup$
  • $\begingroup$ Thanks a lot! This works perfectly for both cases $\endgroup$ – Ilya Oct 14 '18 at 15:18
  • $\begingroup$ @Ilya I'm glad I could help. If you try this with more examples, and one doesn't work, let me know and I'll see if I can do something. Cheers! $\endgroup$ – AccidentalFourierTransform Oct 14 '18 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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