[genius] Mon Feb 16 14:26:02 2015 Jiri (George) Lebl <jirka 5z com>
- From: George Lebl <jirka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [genius] Mon Feb 16 14:26:02 2015 Jiri (George) Lebl <jirka 5z com>
- Date: Mon, 16 Feb 2015 20:26:37 +0000 (UTC)
commit ac98dfbb744e619c9228cafb315acf2411573f50
Author: Jiri (George) Lebl <jiri lebl gmail com>
Date: Mon Feb 16 14:26:09 2015 -0600
Mon Feb 16 14:26:02 2015 Jiri (George) Lebl <jirka 5z com>
* examples/fourier-series-plotting.gel: Replace the hand coded
graph with more general code that can be used to show fourier
series for more functions
ChangeLog | 6 +++
examples/Makefile.am | 2 +-
examples/fourier-series-half-sawtooth.gel | 52 -----------------------------
examples/fourier-series-plotting.gel | 41 ++++++++++++++++++++++
4 files changed, 48 insertions(+), 53 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 524e6a4..13510aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Feb 16 14:26:02 2015 Jiri (George) Lebl <jirka 5z com>
+
+ * examples/fourier-series-plotting.gel: Replace the hand coded
+ graph with more general code that can be used to show fourier
+ series for more functions
+
Fri Feb 13 11:46:57 2015 Jiri (George) Lebl <jirka 5z com>
* gtkextra/*.c: remove the inline from roundint. Probably not
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 21cdcc4..b93e9e0 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -17,7 +17,7 @@ example_DATA = \
taylor-exp.gel \
taylor-sin.gel \
fourier-series-animation.gel \
- fourier-series-half-sawtooth.gel \
+ fourier-series-plotting.gel \
rsa.gel \
easy-matrix-examples.gel \
peano.gel
diff --git a/examples/fourier-series-plotting.gel b/examples/fourier-series-plotting.gel
new file mode 100644
index 0000000..5b40698
--- /dev/null
+++ b/examples/fourier-series-plotting.gel
@@ -0,0 +1,41 @@
+# Category: Differential Equations
+# Name: Fourier series plotting
+
+# Define the function. We will only use it on [-1,1] and extend
+# periodically. There are a number of functions to try. The more
+# regularity the function has (after extending periodically) the
+# faster the convergence.
+function f(x) = (
+ if x < 0 then 0 else x # half sawtooth
+ #0.5*(x+1) # sawtooth
+ #if x < 0 then 0 else 1 # step function
+ #|x| # function with corners
+ #-(x-1)*(x+1) # function with sharp corner
+ #((x-1)*(x+1))^2 # function with first derivative
+);
+
+LinePlotWindow=[-2,2,-0.5,1.5];
+LinePlotDrawLegends=false;
+
+LinePlotClear();
+PlotWindowPresent(); # Make sure the window is raised
+
+N = 20; #number of harmonics to do
+
+LinePlot(PeriodicExtension(f,-1,1));
+
+print("Computing...");
+#Compute the first N harmonics. c will be a vector of
+#two vectors c@(1) are the cosine coefficients, c@(2) are
+#the sine coefficients
+c = NumericalFourierSeriesCoefficients (f, 1, N);
+a = c@(1);
+b = c@(2);
+
+for n=1 to N do (
+ #wait(1); if you want to slow the anumation
+ fs = FourierSeriesFunction (a@(1:n), b@(1:n), 1);
+ print("Plotting up to the " + n + "th harmonic...");
+ LinePlot(PeriodicExtension(f,-1,1), fs);
+);
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]