>> From: Maple Group
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Sun, 20 Feb 2000 00:29:22 -0800 (PST)
From: Robert Israel
To:
Subject: System of second order nonlinear ODEs?
Mehmet Ali Suzen wrote:
|> restart:with(DEtools):with(plots):#see help on dsolve,numeric
|> for phi in [-Pi,Pi] do
|> de1[phi] := (D@@2)(x)(t)=y(t)^2-x(t)^2, (D@@2)(y)(t)=2*x(t)*y(t){}:
|> init1 := x(0)=(cos(phi))^2, D(x)(0)=0, y(0)=(sin(phi))^2, D(y)(0)=0{}:
|> F := dsolve(de1[phi] union init1, x(t),y(t){},type=numeric): od:
|> #NULL RESULT#
No, it isn't a null result. You don't see a result because you're
ending the commands with colons rather than semicolons. But you have
actually defined F twice here, first with phi = -Pi and second with
phi = Pi. So for example:
> F(2);
d
[t = 2, y(t) = 0, -- y(t) = 0, x(t) = -.2311661300856104,
dt
d
-- x(t) = -.8215242100525825]
dt
| for specific one curve
|> restart:with(DEtools):with(plots):#see help on dsolve,numeric
|> de1 := (D@@2)(x)(t)=y(t)^2-x(t)^2, (D@@2)(y)(t)=2*x(t)*y(t){}:
|> init1 := x(0)=0, D(x)(0)=0, y(0)=1, D(y)(0)=0{}:
|> F := dsolve(de1 union init1, x(t),y(t){},type=numeric);
|> F := proc(rkf45_x) ... end
|> odeplot(F,[y(t),x(t)],-1..1);
|>#ONE CURVE but seems wrong for me????#
I don't know, it looks quite correct to me. Perhaps you meant to have
[x(t),y(t)] instead of [y(t),x(t)]? Note also that the solution
has the symmetry t -> -t, x -> x, y -> y, i.e. the path for t in [0,1]
is the same as the path for t in [-1,0], in the opposite direction.
I wonder if your differential equation is really what you want.
This one has some solutions of the form
x = 3 (t-t0)^(-2)
y = 3^(3/2) (t-t0)^(-2)
and it appears that the solution for your initial condition
approaches this one with t0 approximately 3.25.
| Q2) Are there any more efficient ways to visualize system of second
| order nonlinear ODEs as family of curves on one graphic?
If you want to see solutions with several initial conditions, you
can produce the plots separately and combine them using "display".
Thus:
> for k from 0 to 15 do
init[k]:= x(0) = cos(k*2*Pi/16), y(0) = sin(k*2*Pi/16), D(x)(0)=0,
D(y)(0) = 0{};
F[k]:= dsolve(de1 union init[k], x(t),y(t){},type=numeric);
P[k]:= odeplot(F[k],[x(t),y(t)],0..3);
od:
display(seq(P[k],k=0..15){},view=[-5..5,-5..5]);
It appears that these solutions either go off to infinity like
x = 3 (t-t0)^(-2), y = 3^(3/2) (t-t0)^(-2)
or
x = 3 (t-t0)^(-2), y = -3^(3/2) (t-t0)^(-2)
or
x = -6 (t-t0)^(-2), y = 0. Two of the solutions in this picture (k=5
and k=11) haven't done so yet, but if you follow them for a longer t
interval they will make sharp turns and go off to infinity along the
negative x axis.
Robert Israel
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Mon, 21 Feb 2000 11:39:29 +0100
From: Preben Alsholm
To:
Subject: System of second order nonlinear ODEs?
The following may be what you want. I have made a few changes in your code.
restart: with(DEtools):with(plots):
> de:=(D@@2)(x)(t)=y(t)^2-x(t)^2, (D@@2)(y)(t)=2*x(t)*y(t){}:
> for k from 0 to 8 do
phi:=-Pi+k*Pi/4;
init:= x(0)=cos(phi), D(x)(0)=0, y(0)=sin(phi), D(y)(0)=0{};
F[k] := dsolve(de union init, x(t),y(t){},type=numeric) od:
> for k from 0 to 8 do
p.k:=odeplot(F[k],[x(t),y(t)],-1..1)
od:
> pc:=plot([cos(t),sin(t),t=-Pi..Pi],color=blue):
> display(seq(p.k,k=0..8),pc,axes=none,scaling=constrained);
Preben Alsholm
IFAK, Technical University of Denmark
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Mon, 21 Feb 2000 09:36:20 -0500
From: "Douglas B. Meade"
To:
Subject: System of second order nonlinear ODEs?
MUG and Mehmet,
There are a number of fundamental errors with your attempt to create a
phase portrait for the system of 2nd order ODEs listed in your original
posting.
Instead of trying to outline each problem, I will simply give the way in
which I would approach this problem (with a few comments as needed in
the code).
> restart; with(DEtools): with(plots):
# The ODE does not depend on phi; only the IC does.
> de := (D@@2)(x)(t)=y(t)^2-x(t)^2, (D@@2)(y)(t)=2*x(t)*y(t){};
> ic := phi -> x(0)=(cos(phi))^2, D(x)(0)=0, y(0)=(sin(phi))^2, D(y)(0)=0{};
# Let's define the solution as a procedure that takes phi as an argument.
> F := phi -> dsolve(de union ic(phi), x(t),y(t){},type=numeric):
# Now, to draw the one curve in your message:
> odeplot( F(0), [x(t),y(t)], 0..1 );
# Note that I have reversed x and y to produce a more typical phase portrait.
# The solution look reasonable to me -- it moves along the x-axis towards
# origin (it move beyond the origin if you extend the time interval).
# Note also that I have changed the initial time to t=0 to better illustrate
# the initial condition.
# To create an animation of solutions we first create a list of phi values:
> philist := [ Pi*i/8, $ i=-8..8 ];
# The following seq command replaces the for ... do ... od command.
> Fplot := [ seq( odeplot( F(phi), [x(t),y(t)], 0..1, phi=philist ) ]:
# An animated sequence of solution curves can be
> display( [Fplot], insequence=true );
# And, to see all plots simultaneously:
> display( [Fplot] );
# Note that there are not 17 curves; this is due to the symmetry of the
# original IVP.
I hope this has been helpful for you,
Doug
-----------------------------------------------------------------------
Douglas B. Meade Phone: (803) 777-6183 FAX: (803) 777-6527
Department of Mathematics URL: http://www.math.sc.edu/~meade/
USC, Columbia, SC 29208 E-mail:
|