TransWikia.com

Solve IVP in a implicit form

Mathematica Asked on May 17, 2021

DSolve[(5 y[x]^4 + 3 y[x]^2 + Exp[y[x]]) D[y[x], x] == 
       Cos[x] && y[0] == 0, y[x], x]
    
(*{{y[x] -> InverseFunction[E^#1 + #1^3 + #1^5 &][1 + Sin[x]]}}*)

solves the IVP $(5y^4+3y^2+e^y)y’=cos x$, $y(0)=0$. Is it possible to have an output in an implicit form, that is, $y^5+y^3+e^y=sin x+1$, e.g.

{{y[x] -> y[x]^5+y[x]^[3]+Exp[y] == Sin[x] + 1}}

2 Answers

Found a way (caveat: it temporarily hobbles an internal function while DSolve is running):

Block[{DSolve`DSolveSolve = Solve},
 DSolve[
  (5 y[x]^4 + 3 y[x]^2 + Exp[y[x]]) D[y[x], x] == Cos[x] &&
    y[0] == 0, y, x]
 ]

(*  Solve[E^y[x] + y[x]^3 + y[x]^5 == 1 + Sin[x], y[x]]  *)

Note that DSolve can currently be expected to evolve rather often. It is unknown for just how many versions this hack will continue to work.

Alternative. This should work in all versions. Here's a function I wrote some time ago to convert a solution to an equation (for a broader range of solutions to both DSolve and NDSolve). It returns an Inactive, as opposed to an inert, Solve[] call.

ClearAll[toImplicitSolution];
toImplicitSolution::usage = 
  "toImplicitSolution[sol] converts a solution to an implicit solution.";
toImplicitSolution::IRoot = 
  "A Root object is being inverted; extraneous solutions may be introduced.";
toImplicitSolution[sol_] :=
  sol /. {
    HoldPattern[{x_[t_] -> InverseFunction[f_][a_]}] :> 
     Inactive[Solve][f[x[t]] == a, x[t]],
    HoldPattern[{x_ -> Verbatim[Function][{t_}, InverseFunction[f_][a_]]}] :> 
     Inactive[Solve][f[x[t]] == a, x[t]],
    HoldPattern[{x_ -> Verbatim[Function][{t_}, Root[f_, n_]]}] /;
       (Message[toImplicitSolution::IRoot]; True) :> 
     Inactive[Solve][f[x[t]] == 0, x[t]],
    HoldPattern[ff : {(_ -> Verbatim[Function][{t_}, _]) ..}] :> 
     Inactive[Solve][
      Thread[Through[ff[[All, 1]][t]] == Through[ff[[All, 2]][t]]], 
      Through[ff[[All, 1]][t]]],
    HoldPattern[ff : {(_ -> _InterpolatingFunction) ..}] :> 
     Inactive[Solve][
      Thread[Through[ff[[All, 1]][[FormalT]]] == Through[ff[[All, 2]][[FormalT]]]], 
      Through[ff[[All, 1]][[FormalT]]]]};

dsol = DSolve[(5 y[x]^4 + 3 y[x]^2 + Exp[y[x]]) D[y[x], x] == Cos[x] &&
     y[0] == 0, y, x];

toImplicitSolution[dsol]

(*  {Inactive[Solve][E^y[x] + y[x]^3 + y[x]^5 == 1 + Sin[x], y[x]]}  *)

Correct answer by Michael E2 on May 17, 2021

Rewrite your ode for the function x[y]

X = DSolveValue[{(5 y ^4 + 3 y ^2 + Exp[y ])  == x'[y] Cos[x[y]],x[0] == 0} , x , y]
(*Function[{y}, -ArcSin[1 - E^y - y^3 - y^5]]*)

Sin[X[y]]
(*-1 + E^y + y^3 + y^5*)

Answered by Ulrich Neumann on May 17, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP