Message Boards Message Boards

0
|
3994 Views
|
5 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Truncated solution plot of ODE

Posted 2 years ago

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.

enter image description here

Question is: How can I get missed part of the solution graph?

Thank you, Marek

POSTED BY: Marek Wojcik
5 Replies
Posted 2 years ago

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.

POSTED BY: Marek Wojcik

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.

POSTED BY: Mariusz Iwaniuk
Posted 2 years ago

Correct, solution behavior is clear.

Problem concerns the plotting capabilities (and relevant options) in order to see different solution regimes.

POSTED BY: Marek Wojcik

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*)
POSTED BY: Mariusz Iwaniuk
Posted 2 years ago

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

POSTED BY: Michael Helmle
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