Message Boards Message Boards

Solving differential equation in Mathematica without ProductLog

Posted 1 year ago

Im trying to solve this Differential Equation with Mathematica to see if the result equals the result I got by solving the equation by hand.

However Mathematica gives me an answer with ProductLog which doesn't make sence to me.

Answer given when solving by hand: y = xLn|((x+y)^2)/(x)| + Cx, where C is constant of integration

5 Replies

Okay, but when i solve it by hand i make the substitution y = vx, can this be done with mathematica to give the anwer that i get by hand and not the one that explicit one which mathematica gives (ProducLog etc...)

  S = DSolveChangeVariables[
     Inactive[DSolve][y'[x] == (x^2 + y[x]^2)/(x*y[x] - x^2), y, x], v, 
     x, y[x] == v[x]*x] // FullSimplify

   S // Activate
   (*{{v -> Function[{x}, -1 - 
        2 ProductLog[-(1/2) Sqrt[E^(-1 - C[1])/x]]]}, {v -> 
      Function[{x}, -1 - 2 ProductLog[1/2 Sqrt[E^(-1 - C[1])/x]]]}}*)

Looks the same.

POSTED BY: Mariusz Iwaniuk

This is a simulation of doing it by hand step-by-step with your substitution:

(y'[x] == (x^2 + y[x]^2)/(x*y[x] - x^2)) /. y -> Function[t, t*v[t]]
Solve[%, v'[x]][[1, 1]] /. Rule -> Equal // Simplify
DivideSides[%, %[[2]] x, GenerateConditions -> False]
ApplySides[Integrate[#, x] &, %]
SubtractSides[%, 0 == C[1]]
% /. v -> Function[t, y[t]/t]
Solve[%, y[x]]
POSTED BY: Gianluca Gorni

Mathematica give you solution with explicit form it's a general solving diff equation.

EQ = y'[x] == (x^2 + y[x]^2)/(x*y[x] - x^2);
sol = DSolve[EQ, y, x] // Quiet
EQ /. sol[[1]] // FullSimplify(*A correct solution*)

Your solution by hand are implicit form:

Solve[y == x*Log[((x + y)^2)/(x)] + C[1]*x, y] // PowerExpand

(*{{y -> -x - 
    2 x ProductLog[-(E^(1/2 (-1 - C[1]))/(2 Sqrt[x]))]}, {y -> -x - 
    2 x ProductLog[E^(1/2 (-1 - C[1]))/(2 Sqrt[x])]}}*)

Regards M.I.

POSTED BY: Mariusz Iwaniuk

From here give you solution with implicit form(with Solve),but is very mesy:

  On[$Assumptions];  (*shows when $Assumptions is changed*)
  Module[{assum = True}, 
   Internal`InheritedBlock[{Solve, $Assumptions}, Unprotect[Solve];
    call : Solve[eq_, v_, opts___] /; ! TrueQ[$in] := 
     Block[{$in = True, $res1, $res2}, 
      Check[(*Use Check to try default settings& respond to \
  messages*)$res1 = call (*try original call*),(*Check[]*)
       Print["Trying \"ReduceOptions\" -> \"UseTranscendentalSolve\" -> \
  True on ", HoldForm[call]];
       With[{redopts = SystemOptions["ReduceOptions"]}, 
        Internal`WithLocalSettings[
          SetSystemOptions[
           "ReduceOptions" -> "UseTranscendentalSolve" -> True],(*I`WLS:
          init*)$res2 = Solve[eq, v, GeneratedParameters -> $S, opts];
          $res2 = $res2 /. 
            ConditionalExpression[e_, 
              c_] :>(*map condition to assumption*)($Assumptions = \
  $Assumptions && c;(*for solvers and Simplify[]*)
              assum = assum && c;(*for addConditions[] at end*)e);
          Print[
           "$Assumptions now ", $Assumptions];(*context for \
  On[$Assumptions]*)$res2 = Simplify[$res2];
          Print["Result= ", $res2], 
          SetSystemOptions[
           redopts]                                        (*I`WLS:
          reset*)];];
       If[FreeQ[$res2, 
         Solve], $res2, $res1],(*Check[]*){Solve::ifun}]];
    Protect[Solve];
    sol = DSolve[DSolve[y'[x] == (x^2 + y[x]^2)/(x*y[x] - x^2), y, x]];
    Print["$Assumptions finally ", $Assumptions];(*context for \
  On[$Assumptions]*)sol = sol /. addConditions[assum]]]
  Off[$Assumptions];
POSTED BY: Mariusz Iwaniuk
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract