[genius] Fri Dec 16 17:36:16 2016 Jiri (George) Lebl <jirka 5z com>
- From: George Lebl <jirka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [genius] Fri Dec 16 17:36:16 2016 Jiri (George) Lebl <jirka 5z com>
- Date: Fri, 16 Dec 2016 23:36:00 +0000 (UTC)
commit ce147f2a094d6eab03184edbdf2fe9e9774b9c7e
Author: Jiri (George) Lebl <jiri lebl gmail com>
Date: Fri Dec 16 17:36:33 2016 -0600
Fri Dec 16 17:36:16 2016 Jiri (George) Lebl <jirka 5z com>
* examples/complex-analysis-argument-principle.gel: Add argument
principle example
* examples/complex-analysis-mandelbrot-set.gel: slightly modify, try
more iterations
ChangeLog | 8 ++
examples/Makefile.am | 1 +
examples/complex-analysis-argument-principle.gel | 103 ++++++++++++++++++++++
examples/complex-analysis-mandelbrot-set.gel | 14 ++--
4 files changed, 119 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e66aa9b..c63e5f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Dec 16 17:36:16 2016 Jiri (George) Lebl <jirka 5z com>
+
+ * examples/complex-analysis-argument-principle.gel: Add argument
+ principle example
+
+ * examples/complex-analysis-mandelbrot-set.gel: slightly modify, try
+ more iterations
+
Tue Nov 22 14:51:35 2016 Jiri (George) Lebl <jirka 5z com>
* src/funclib.c: fix doc string for ErrorFunction, Thanks to
diff --git a/examples/Makefile.am b/examples/Makefile.am
index ff7518e..df2f16f 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -28,6 +28,7 @@ example_DATA = \
complex-analysis-mandelbrot-define.gel \
complex-analysis-wandering-ball.gel \
complex-analysis-mesh.gel \
+ complex-analysis-argument-principle.gel \
riemann-integral.gel \
riemann-integral-darboux.gel
diff --git a/examples/complex-analysis-argument-principle.gel
b/examples/complex-analysis-argument-principle.gel
new file mode 100644
index 0000000..40a6ab8
--- /dev/null
+++ b/examples/complex-analysis-argument-principle.gel
@@ -0,0 +1,103 @@
+# Category: Complex Analysis
+# Name: Finding roots via argument principle
+#
+# Shows a bouncing wandering ball and prints the number of roots minus poles of
+# a function within the ball to the console. When roots detected the ball
+# turns green, for poles, it turns red. If the mouse is within the plot window
+# then the ball will be over the mouse.
+
+
+#The function to try, (must be able to take symbolic derivative, otherwise
+#set df below!)
+
+function f(z) = (z-5i-5)^3*(z+5i-10)/(z+5i+5);
+#function f(z) = (z-4+1i)*(z-3)*(z-5i);
+#function f(z) = sin(2*z)*(z-5i+5)*(z+5);
+#function f(z) = sin(pi*z);
+
+df = SymbolicDerivative(f);
+
+LinePlotDrawLegends = false;
+PlotWindowPresent(); # Make sure the window is raised
+LinePlotClear(); # make sure we are in the line plot mode
+
+#approximately square grid
+LinePlotWindow = [-13,13,-10,10];
+
+#confine possibly to a smaller window.
+#You can also zoom out during the animation.
+#confine_window = [-8,8,-7,7];
+confine_window = LinePlotWindow;
+
+#the circle
+radius = 3;
+step = 0.1;
+
+circlepts = ApplyOverMatrix((0:(120))',`(k)=radius*exp(k*1i*2*pi/(120)));
+
+function draw_ball(pt,N) = (
+ PlotCanvasFreeze ();
+ LinePlotClear ();
+
+ LinePlotDrawLine (pt + circlepts, "color",
+ if N>0 then "green" else if N<0 then "red" else "blue");
+
+ PlotCanvasThaw ();
+);
+
+dir = exp(1i*rand()*2*pi);
+pt = 0;
+lastp = null;
+
+function NumberOfZeros(pt) = (
+ N = (1/(2*pi))*CompositeSimpsonsRule(`(t)=(
+ #f'(z)/f(z)
+ ( df(pt+radius*exp(1i*t)) / f(pt+radius*exp(1i*t)) ) *
+ # dz/i
+ radius*exp(1i*t)
+ ),0,2*pi,20);
+ return round(Re(N));
+);
+
+while true do (
+ p = LinePlotMouseLocation ();
+ if IsNull(p) then break;
+
+ # if mouse within window, use that
+ if confine_window@(1) <= p@(1) <= confine_window@(2) and
+ confine_window@(3) <= p@(2) <= confine_window@(4) then (
+ pt = p@(1) + 1i*p@(2);
+ # if at the same point, then just try again;
+ if pt == lastp then (wait(0.0001);continue);
+ lastp = pt
+ );
+
+ N = NumberOfZeros(pt);
+ draw_ball(pt,N);
+ print ("Zeros-Poles within ball: " + N + " ... may be nonsense if zero/pole on circle");
+
+ # Now wander around
+
+ pt = pt+step*dir;
+
+ if (Re(pt) < confine_window@(1)+radius) then (
+ pt = (confine_window@(1)+radius) + 1i*Im(pt);
+ dir = -1i*conj(1i*dir)
+ );
+ if (Re(pt) > confine_window@(2)-radius) then (
+ pt = (confine_window@(2)-radius) + 1i*Im(pt);
+ dir = -1i*conj(1i*dir)
+ );
+ if (Im(pt) < confine_window@(3)+radius) then (
+ pt = Re(pt) + 1i*(confine_window@(3)+radius);
+ dir = conj(dir)
+ );
+ if (Im(pt) > confine_window@(4)-radius) then (
+ pt = Re(pt) + 1i*(confine_window@(4)-radius);
+ dir = conj(dir)
+ );
+
+ dir = dir*exp(1i*(rand()*0.2-0.1));
+
+ wait(0.0001)
+);
diff --git a/examples/complex-analysis-mandelbrot-set.gel b/examples/complex-analysis-mandelbrot-set.gel
index 4517ea0..a644c65 100644
--- a/examples/complex-analysis-mandelbrot-set.gel
+++ b/examples/complex-analysis-mandelbrot-set.gel
@@ -4,7 +4,7 @@
# Draw the Mandelbrot set
#
-iterations = 10;
+iterations = 30;
LinePlotWindow = [-2,2,-2,2];
@@ -29,13 +29,13 @@ for x = -2.0 to 2.0 by 0.02 do (
z = z^2+c;
if |z| >= 2.0 then break
);
- if m == iterations then (
+ if m == iterations then
points = [points;c];
- increment k;
- # every 100 point display intermediate picture
- if k % 100 == 0 then
- DrawThePlot()
- )
+
+ increment k;
+ # every 500's point display intermediate picture
+ if k % 500 == 0 then
+ DrawThePlot()
)
);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]