I am trying to plot the solutions to a differential equation
ClearAll;
eqn = y'[x] == (2 x + y[x] + 2)/(2 x + y[x] - 4);
solution = DSolve[eqn, y[x], x]
which gives
{{y[x] -> -2 (-2 + x) -
2 (1 + ProductLog[-E^(-1 - (3 x)/2 + C[1])])}}
and then plot it
sol1 = Table[ySol = (y[x] /. solution) /. C[1] -> Cval, {Cval, -20, 20, 0.5}];
sol2 = Table[ySol = (y[x] /. solution) /. C[1] -> Cval - Pi*I, {Cval, -20, 20, 0.5}];
sol = Append[sol1, sol2];
Plot[sol, {x, -4, 4}, PlotRange -> {-2, 8}]
which gives
The upper integral lines stop where the derivative becomes infinite, but they should continue (bending to the right)? How can I achieve this?
Also, is there really no way to get DSolve
to produce an implicit solution to this differential equation?
dsolve(ode,'implicit')
it gives thisx/3 - y(x)/3 + (2*ln(y(x) + 2*x - 2))/3 - c__1 = 0
you can translate to Mathematica and see. changeln
toLog
andc__1
toC[1]
May be in version 15.0 of Mathematica such an option will be added. $\endgroup$Log[(y + 2*x - 2)^2]
instead of2*Log[(y + 2*x - 2)]
, then it produces the whole plot. So maybe a bug in Maple? $\endgroup$ContourPlot
- first original solution and then replace2*Log[(y + 2*x - 2)]
withLog[(y + 2*x - 2)^2]
. $\endgroup$