From 23b53a46d263a30a466ee0d48543b6ed64f29141 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sat, 29 Dec 2018 12:45:47 +1100 Subject: Article about area under the curve for complex valued integrals --- project/assets/css/default.css | 13 ++ project/assets/css/integral.css | 7 + project/assets/dld/integral_scripts.zip | Bin 0 -> 2018 bytes project/assets/img/cos_pi_x.png | Bin 0 -> 27833 bytes project/assets/img/minus_one_exp_x_full_plot.png | Bin 0 -> 63434 bytes .../img/minus_one_exp_x_real_values_only.png | Bin 0 -> 8873 bytes project/assets/img/sin_pi_x.png | Bin 0 -> 27281 bytes project/complexity.yml | 1 + project/scripts/cos_pi_x.py | 36 +++ project/scripts/minus_one_exp_x.py | 36 +++ project/scripts/minus_one_scatter.py | 34 +++ project/scripts/sin_pi_x.py | 36 +++ project/templates/index.html | 3 + project/templates/integral.html | 242 +++++++++++++++++++++ 14 files changed, 408 insertions(+) create mode 100644 project/assets/css/integral.css create mode 100644 project/assets/dld/integral_scripts.zip create mode 100644 project/assets/img/cos_pi_x.png create mode 100644 project/assets/img/minus_one_exp_x_full_plot.png create mode 100644 project/assets/img/minus_one_exp_x_real_values_only.png create mode 100644 project/assets/img/sin_pi_x.png create mode 100755 project/scripts/cos_pi_x.py create mode 100755 project/scripts/minus_one_exp_x.py create mode 100755 project/scripts/minus_one_scatter.py create mode 100755 project/scripts/sin_pi_x.py create mode 100644 project/templates/integral.html diff --git a/project/assets/css/default.css b/project/assets/css/default.css index fb1de72..83cd85a 100644 --- a/project/assets/css/default.css +++ b/project/assets/css/default.css @@ -21,6 +21,19 @@ div.precontain { } +div.mathblock { + display: inline-block; + text-align: left; + background-color: #ffa5a5; + border-radius: 1.5em; + padding: 2em 2em 2em 2em; + margin: 1em 2em 1em 2em; + /* width should be equal to code and pre, but for some reason this needs 45em instead of 60em... bug? */ + /* what are the default widths, margins, and paddings used in browsers anyway? */ + width: 45em; +} + + code { display: inline-block; text-align: left; diff --git a/project/assets/css/integral.css b/project/assets/css/integral.css new file mode 100644 index 0000000..94130ec --- /dev/null +++ b/project/assets/css/integral.css @@ -0,0 +1,7 @@ + + +table#component { + margin: auto; +} + + diff --git a/project/assets/dld/integral_scripts.zip b/project/assets/dld/integral_scripts.zip new file mode 100644 index 0000000..82ad952 Binary files /dev/null and b/project/assets/dld/integral_scripts.zip differ diff --git a/project/assets/img/cos_pi_x.png b/project/assets/img/cos_pi_x.png new file mode 100644 index 0000000..7254624 Binary files /dev/null and b/project/assets/img/cos_pi_x.png differ diff --git a/project/assets/img/minus_one_exp_x_full_plot.png b/project/assets/img/minus_one_exp_x_full_plot.png new file mode 100644 index 0000000..1927f52 Binary files /dev/null and b/project/assets/img/minus_one_exp_x_full_plot.png differ diff --git a/project/assets/img/minus_one_exp_x_real_values_only.png b/project/assets/img/minus_one_exp_x_real_values_only.png new file mode 100644 index 0000000..f8cea87 Binary files /dev/null and b/project/assets/img/minus_one_exp_x_real_values_only.png differ diff --git a/project/assets/img/sin_pi_x.png b/project/assets/img/sin_pi_x.png new file mode 100644 index 0000000..9996cd5 Binary files /dev/null and b/project/assets/img/sin_pi_x.png differ diff --git a/project/complexity.yml b/project/complexity.yml index ef1bccc..8f680f4 100644 --- a/project/complexity.yml +++ b/project/complexity.yml @@ -20,4 +20,5 @@ unexpanded_templates: - "sokoban.html" - "links.html" - "steelman.html" + - "integral.html" diff --git a/project/scripts/cos_pi_x.py b/project/scripts/cos_pi_x.py new file mode 100755 index 0000000..551c142 --- /dev/null +++ b/project/scripts/cos_pi_x.py @@ -0,0 +1,36 @@ +#!/usr/bin/python + + +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.patches import Polygon + + +plt.rcParams['legend.fontsize'] = 10 + +fig = plt.figure () +ax = fig.gca () + +x = np.linspace (-2, 2, 5000) +y = np.cos (np.pi * x) + +ax.plot (x, y, label='$y=Re((-1)^{x})$') +ax.legend () + +a, b = 0, 1 +ix = np.linspace (a, b) +iy = np.cos (np.pi * ix) +verts = [(a,0)] + zip (ix, iy) + [(b,0)] +poly = Polygon (verts, facecolor='0.9', edgecolor='0.5') +ax.add_patch (poly) + +ax.set_xticks ([-2, -1, 1, 2]) +ax.spines['left'].set_position ('center') +ax.spines['right'].set_position ('center') + +ax.set_yticks ([-1, -0.5, 0.5, 1]) +ax.spines['top'].set_position ('center') +ax.spines['bottom'].set_position ('center') + +plt.show () + diff --git a/project/scripts/minus_one_exp_x.py b/project/scripts/minus_one_exp_x.py new file mode 100755 index 0000000..7073b47 --- /dev/null +++ b/project/scripts/minus_one_exp_x.py @@ -0,0 +1,36 @@ +#!/usr/bin/python + + +from mpl_toolkits.mplot3d import Axes3D +import numpy as np +import matplotlib.pyplot as plt + + +plt.rcParams['legend.fontsize'] = 10 + +fig = plt.figure () +ax = fig.gca (projection='3d') + +# the z-axis is vertical in matplotlib +x = np.linspace (-2, 2, 5000) +y = np.sin (np.pi * x) +z = np.cos (np.pi * x) + +ax.plot (x, y, z, label='$y=(-1)^{x}$') +ax.legend () + +ax.set_xlabel ('x', labelpad=7) +ax.set_xticks ([-2, -1, 0, 1, 2]) +ax.xaxis.set_rotate_label (False) + +ax.set_ylabel ('$y_{im}$', labelpad=7) +ax.set_yticks ([1, 0.5, 0, -0.5, -1]) +ax.invert_yaxis () +ax.yaxis.set_rotate_label (False) + +ax.set_zlabel ('$y_{re}$', labelpad=7) +ax.set_zticks ([-1, -0.5, 0, 0.5, 1]) +ax.zaxis.set_rotate_label (False) + +plt.show () + diff --git a/project/scripts/minus_one_scatter.py b/project/scripts/minus_one_scatter.py new file mode 100755 index 0000000..4b26a4f --- /dev/null +++ b/project/scripts/minus_one_scatter.py @@ -0,0 +1,34 @@ +#!/usr/bin/python + + +import numpy as np +import matplotlib.pyplot as plt + + +plt.rcParams['legend.fontsize'] = 10 + +fig = plt.figure () +ax = fig.gca () + +data = np.array([ + [-2, 1], + [-1,-1], + [ 0, 1], + [ 1,-1], + [ 2, 1] +]) +x, y = data.T + +ax.set_xticks ([-2, -1, 1, 2]) +ax.spines['left'].set_position ('center') +ax.spines['right'].set_position ('center') + +ax.set_yticks ([-1, -0.5, 0.5, 1]) +ax.spines['top'].set_position ('center') +ax.spines['bottom'].set_position ('center') + +plt.scatter (x, y, label='$y=(-1)^{x}$') +ax.legend () + +plt.show () + diff --git a/project/scripts/sin_pi_x.py b/project/scripts/sin_pi_x.py new file mode 100755 index 0000000..8436726 --- /dev/null +++ b/project/scripts/sin_pi_x.py @@ -0,0 +1,36 @@ +#!/usr/bin/python + + +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.patches import Polygon + + +plt.rcParams['legend.fontsize'] = 10 + +fig = plt.figure () +ax = fig.gca () + +x = np.linspace (-2, 2, 5000) +y = np.sin (np.pi * x) + +ax.plot (x, y, label='$y=Im((-1)^{x})$') +ax.legend () + +a, b = 0, 1 +ix = np.linspace (a, b) +iy = np.sin (np.pi * ix) +verts = [(a,0)] + zip (ix, iy) + [(b,0)] +poly = Polygon (verts, facecolor='0.9', edgecolor='0.5') +ax.add_patch (poly) + +ax.set_xticks ([-2, -1, 1, 2]) +ax.spines['left'].set_position ('center') +ax.spines['right'].set_position ('center') + +ax.set_yticks ([-1, -0.5, 0.5, 1]) +ax.spines['top'].set_position ('center') +ax.spines['bottom'].set_position ('center') + +plt.show () + diff --git a/project/templates/index.html b/project/templates/index.html index 056231f..dfe396b 100644 --- a/project/templates/index.html +++ b/project/templates/index.html @@ -16,6 +16,9 @@ {% block content %}