How to plot representative graphs of members of the family of solutions of the differential equation using Maple?

416 Views Asked by At

Using this code

  • sol := dsolve(diff(y(x), x) = x*(1-x)/(y(x)*(y(x)-2)), y(x));
  • tplot := {seq(subs(_C1 = i, rhs(sol1)), i = -5 .. 5)};
  • plot(tplot, x = -5 .. 5, y = -5 .. 5);

Generates this enter image description here How can I solve this problem? Using DEplot also generates "pieces" of needed graph (field itself is correct, though).

1

There are 1 best solutions below

1
On BEST ANSWER

Here are a few ideas, using the explicit form:

restart;
sol := [dsolve(diff(y(x), x) = x*(1-x)/(y(x)*(y(x)-2)), y(x))]:

nops(sol);
                           3

#tplot := [seq(subs(_C1 = i, map(rhs,sol))[], i = -5 .. 5)]:
tplot := [
          seq(subs(_C1 = i, map(rhs,sol))[], i = -7 .. -1),
          seq(subs(_C1 = i, map(rhs,sol))[], i = -1 .. 2, 0.33),
          seq(subs(_C1 = i, map(rhs,sol))[], i = 2 .. 7)
          ]:

plot(tplot, x = -5 .. 5, y = -5 .. 5);

enter image description here

#plots:-animate(plot,[map(rhs,sol), x=-5..5, y=-5..5], _C1=-5..-0.5);
#plots:-animate(plot,[map(rhs,sol), x=-5..5, y=-5..5], _C1=-0.5..0.25);
#plots:-animate(plot,[map(rhs,sol), x=-5..5, y=-5..5], _C1=0.25..1.2);
#plots:-animate(plot,[map(rhs,sol), x=-5..5, y=-5..5], _C1=1.2..1.6);
#plots:-animate(plot,[map(rhs,sol), x=-5..5, y=-5..5], _C1=1.6..5);

N:=20:
plots:-display([seq(plot(map(rhs,subs(_C1=5.0+(i-1)*(1.6-(5.0))/(N-1),sol)),
                         x=-5..5, y=-5..5),
                    i=1..N),
                seq(plot(map(rhs,subs(_C1=1.6+(i-1)*(1.2-(1.6))/(N-1),sol)),
                         x=-5..5, y=-5..5),
                    i=1..N),
                seq(plot(map(rhs,subs(_C1=1.2+(i-1)*(0.25-(1.2))/(N-1),sol)),
                         x=-5..5, y=-5..5),
                    i=1..N),
                seq(plot(map(rhs,subs(_C1=0.25+(i-1)*(-0.5-(0.25))/(N-1),sol)),
                         x=-5..5, y=-5..5),
                    i=1..N),
                seq(plot(map(rhs,subs(_C1=-0.5+(i-1)*(-5.0-(-0.5))/(N-1),sol)),
                         x=-5..5, y=-5..5),
                    i=1..N)],
               'insequence'=true);

enter image description here

restart;

interface(warnlevel=0):

DEtools:-DEplot(diff(y(x), x) = x*(1-x)/(y(x)*(y(x)-2)),
                y(x), x=-5..5,
                dirfield=[40,40],
                [
                 y(0)=-2.0, y(0)=-1.0, y(0)=-0.5,
                 y(0)=0.5, y(0)=1.0, y(0)=1.99,
                 y(0)=2.01, y(0)=2.9, y(0)=4,

                 y(3.2)=1, y(3.3)=-1,
                 y(-2.2)=1, y(-2.1)=2.1
                ],
                linecolor=x,
                color=COLOR(RGB,0.6,0.6,0.4),
                numpoints=5000,
                maxfun=20000);

enter image description here

[edit] I should mention that Maple's dsolve command also allows for an implicit form of the solution.

So perhaps you'd prefer this simpler approach:

restart;

DE := diff(y(x), x) = x*(1-x)/(y(x)*(y(x)-2)):

sol:=dsolve(DE, y(x), implicit):

lprint(sol);

    (1/3)*x^3-(1/2)*x^2+(1/3)*y(x)^3-y(x)^2+_C1 = 0

tplot := [seq(subs(_C1 = i, sol), i = -5 .. 5)]:

P := plots:-implicitplot(tplot, x=-5..5, y=-5..5, gridrefine=2):

F := DEtools:-DEplot(diff(y(x), x) = x*(1-x)/(y(x)*(y(x)-2)),
                     y(x), x=-5..5,y=-5..5,
                     dirfield=[40,40], numpoints=2,
                     [y(-2.1)=2.1],
                     color=COLOR(RGB,0.1,0.5,0.1)):

plots:-display(P, F);

enter image description here