[genius] Tue Dec 27 15:42:39 2016 Jiri (George) Lebl <jirka 5z com>



commit 6638883c597bfc4987b655052c6b6f64545c1b97
Author: Jiri (George) Lebl <jiri lebl gmail com>
Date:   Tue Dec 27 15:42:41 2016 -0600

    Tue Dec 27 15:42:39 2016  Jiri (George) Lebl <jirka 5z com>
    
        * examples/duffing-equation-trajectories.gel: example for Duffing
          equation trajectories diverging wildly after some time given a
          small change in initial conditions.
    
        * examples/strange-attractor.gel: use the same equation as above
          for consistency

 ChangeLog                                  |    9 ++++
 examples/Makefile.am                       |    1 +
 examples/duffing-equation-trajectories.gel |   58 ++++++++++++++++++++++++++++
 examples/strange-attractor.gel             |    4 +-
 4 files changed, 70 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0110c5d..be9d8e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Tue Dec 27 15:42:39 2016  Jiri (George) Lebl <jirka 5z com>
+
+       * examples/duffing-equation-trajectories.gel: example for Duffing
+         equation trajectories diverging wildly after some time given a
+         small change in initial conditions.
+
+       * examples/strange-attractor.gel: use the same equation as above
+         for consistency
+
 Mon Dec 26 12:22:27 2016  Jiri (George) Lebl <jirka 5z com>
 
        * Release 1.0.22
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 58bbcc6..939fbab 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -16,6 +16,7 @@ example_DATA = \
        sierpinski.gel \
        standing-waves.gel \
        strange-attractor.gel \
+       duffing-equation-trajectories.gel \
        taylor-exp.gel \
        taylor-sin.gel \
        fourier-series-animation.gel \
diff --git a/examples/duffing-equation-trajectories.gel b/examples/duffing-equation-trajectories.gel
new file mode 100644
index 0000000..a28541f
--- /dev/null
+++ b/examples/duffing-equation-trajectories.gel
@@ -0,0 +1,58 @@
+# Category: Chaos
+# Name: Duffing's equation trajectories
+#
+# Draws Duffing equation trajectories showing a small change
+# in initial conditions means large error after some time. 
+#
+
+# The Duffing equation (converted to an ODE system)
+# x_1' = x_2, x_2' = -0.05x_2 - x_1^3 + 8cos(t)
+function duf(x,y) = [y@(2),-0.05*y@(2)-(y@(1))^3+8*cos(x)];
+
+LinePlotDrawLegends = false;
+PlotWindowPresent(); # Make sure the window is raised
+LinePlotWindow = [-4,4,-6,6];
+LinePlotClear ();
+
+pointblue = [2.0,2.95];
+pointred = [2.0,3.05];
+
+ttinterval = 0.1;
+
+for tt = 0 to 50 by ttinterval do (
+  PlotCanvasFreeze ();
+  
+  # Draw a piece of the trajectory starting at pointblue
+  # and t going from tt to going tt+ttinterval
+  pt = RungeKuttaFull(duf,tt,pointblue,tt+ttinterval,20);
+  
+  #last point is going to be the next starting point
+  pointblue = pt@(rows(pt),2);
+  
+  #flatten the matrix
+  pt = ExpandMatrix(pt);
+  
+  # draw the line
+  LinePlotDrawLine(pt@(,[2,3]),"color","blue");
+
+  # Draw a piece of the red trajectory, similar to the above
+  pt = RungeKuttaFull(duf,tt,pointred,tt+ttinterval,20);
+  pointred = pt@(rows(pt),2);
+  pt = ExpandMatrix(pt);
+  LinePlotDrawLine(pt@(,[2,3]),"color","red");
+
+  PlotCanvasThaw();
+  
+  wait(0.03)
+);
+
+# If you only want to draw the trajectories, comment out the above 
+# loop and just run
+#
+#pt = RungeKuttaFull(duf,0,pointblue,18,1000);
+#pt = ExpandMatrix(pt);
+#LinePlotDrawLine(pt@(,[2,3]),"color","blue");
+#
+#pt = RungeKuttaFull(duf,0,pointred,18,1000);
+#pt = ExpandMatrix(pt);
+#LinePlotDrawLine(pt@(,[2,3]),"color","red");
diff --git a/examples/strange-attractor.gel b/examples/strange-attractor.gel
index d64a942..9ae309f 100644
--- a/examples/strange-attractor.gel
+++ b/examples/strange-attractor.gel
@@ -6,9 +6,9 @@
 #
 
 # The Duffing equation (converted to an ODE system)
-# x_1' = x_2, x_2' = -0.05x_2 - x_1^3 + 7.5cos(t)
+# x_1' = x_2, x_2' = -0.05x_2 - x_1^3 + 8cos(t)
 #
-function duf(t,x) = [x@(2),-0.05*x@(2)-(x@(1))^3+7.5*cos(t)];
+function duf(t,x) = [x@(2),-0.05*x@(2)-(x@(1))^3+8*cos(t)];
 
 # Strobe period
 strobe = 2*pi;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]