mwojcik23
(Marek Wojcik)
February 27, 2022, 8:14am
1
Hello,
I tried to get a plot of function being solution of the following ODE:
sol = DSolve[{y'[x] == y[x]^2 - y[x]^3, y[0] == 0.001}, y[x], x]
solution I got is:
{{y[x] ->
InverseFunction[Log[1 - #1] - Log[#1] + 1/#1 &][1006.91 - x]}}
which i tried to visualize using:
Plot[y[x] /. sol, {x, 0, 2000}]
Unfortunately, plateau after x>1000 is not shown.
Question is: How can I get missed part of the solution graph?
Thank you,
Marek
mhelmle
(Michael Helmle)
February 27, 2022, 9:08am
2
Hello Marek,
the plateau is not shown due to the plotrange that Mathematica decided. Use
Plot[y[x]/.sol, {x,0,2000},PlotRange-> All]
Regards,
Michael
Other options:
sol = DSolve[{y'[x] == y[x]^2 - y[x]^3, y[0] == 10^-3}, y[x], x]
Plot[y[x] /. sol, {x, 0, 2000}, PlotRange -> Full]
Plot[y[x] /. sol, {x, 0, 2000}, PlotRange -> {{0, 2000}, {-1/2, 3/2}}]
We can convert to implict solution:
S1 = ((sol[[1, 1, 2, 0, 1]] /@ {y})[[1]]) == sol[[1, 1, 2, 1]](*Easy way*)
(*1/y + Log[1 - y] - Log[y] == 1000 - x - Log[1000/999] + Log[1000]*)
ContourPlot[Evaluate@S1, {x, 0, 2000}, {y, 0, 1}, MaxRecursion -> 2,
PlotPoints -> 100](*Plot implicit solution*)
mwojcik23
(Marek Wojcik)
February 27, 2022, 10:15am
4
Thank you for the answers.
Indeed, plateau starts to appear slightly after using PlotRange. However, I cannot see it beyond say 1018, using proposed solutions.
Because if x goes to Infinity then y goes to 1.
Or another way:
M = Solve[S1 // FullSimplify, x](*Solve for x*)
Limit[x /. M[[1]], y -> 1]
(*Infinity*)
If y goes to 1 then x goes to Infinity.
mwojcik23
(Marek Wojcik)
February 27, 2022, 1:30pm
6
Correct, solution behavior is clear.
Problem concerns the plotting capabilities (and relevant options) in order to see different solution regimes.