diff options
author | Jed Barber <jjbarber@y7mail.com> | 2018-12-29 12:45:47 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2018-12-29 12:45:47 +1100 |
commit | 23b53a46d263a30a466ee0d48543b6ed64f29141 (patch) | |
tree | 9bcb57d4370f6edb93caf5ea6605ea211cd776ff | |
parent | 78e64f219693800130e53809e5c0ec13b445c9fc (diff) |
Article about area under the curve for complex valued integrals
-rw-r--r-- | project/assets/css/default.css | 13 | ||||
-rw-r--r-- | project/assets/css/integral.css | 7 | ||||
-rw-r--r-- | project/assets/dld/integral_scripts.zip | bin | 0 -> 2018 bytes | |||
-rw-r--r-- | project/assets/img/cos_pi_x.png | bin | 0 -> 27833 bytes | |||
-rw-r--r-- | project/assets/img/minus_one_exp_x_full_plot.png | bin | 0 -> 63434 bytes | |||
-rw-r--r-- | project/assets/img/minus_one_exp_x_real_values_only.png | bin | 0 -> 8873 bytes | |||
-rw-r--r-- | project/assets/img/sin_pi_x.png | bin | 0 -> 27281 bytes | |||
-rw-r--r-- | project/complexity.yml | 1 | ||||
-rwxr-xr-x | project/scripts/cos_pi_x.py | 36 | ||||
-rwxr-xr-x | project/scripts/minus_one_exp_x.py | 36 | ||||
-rwxr-xr-x | project/scripts/minus_one_scatter.py | 34 | ||||
-rwxr-xr-x | project/scripts/sin_pi_x.py | 36 | ||||
-rw-r--r-- | project/templates/index.html | 3 | ||||
-rw-r--r-- | project/templates/integral.html | 242 |
14 files changed, 408 insertions, 0 deletions
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 Binary files differnew file mode 100644 index 0000000..82ad952 --- /dev/null +++ b/project/assets/dld/integral_scripts.zip diff --git a/project/assets/img/cos_pi_x.png b/project/assets/img/cos_pi_x.png Binary files differnew file mode 100644 index 0000000..7254624 --- /dev/null +++ b/project/assets/img/cos_pi_x.png diff --git a/project/assets/img/minus_one_exp_x_full_plot.png b/project/assets/img/minus_one_exp_x_full_plot.png Binary files differnew file mode 100644 index 0000000..1927f52 --- /dev/null +++ b/project/assets/img/minus_one_exp_x_full_plot.png 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 Binary files differnew file mode 100644 index 0000000..f8cea87 --- /dev/null +++ b/project/assets/img/minus_one_exp_x_real_values_only.png diff --git a/project/assets/img/sin_pi_x.png b/project/assets/img/sin_pi_x.png Binary files differnew file mode 100644 index 0000000..9996cd5 --- /dev/null +++ b/project/assets/img/sin_pi_x.png 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 %} <ul class="index"> + <li><a href="/integral.html">Area Under the Curve of a Complex Integral</a><br> + <span class="post">(Posted 29/12/2018)</span></li> + <li><a href="/steelman.html">D, Parasail, Pascal, and Rust vs The Steelman</a><br> <span class="post">(Posted 29/10/2017)</span></li> diff --git a/project/templates/integral.html b/project/templates/integral.html new file mode 100644 index 0000000..0e5307b --- /dev/null +++ b/project/templates/integral.html @@ -0,0 +1,242 @@ + +{% extends "base.html" %} + + + +{% block title %}Area Under the Curve of a Complex Integral{% endblock %} + + + +{% block style %} + <link href="/css/integral.css" rel="stylesheet"> +{% endblock %} + + + +{% block content %} + +<h4>Area Under the Curve of a Complex Integral</h4> + +<p>Scripts used to generate graphs: <a href="/dld/integral_scripts.zip">Link</a></p> + +<h5>29/12/2018</h5> + +<p>A definite integral can be represented on the xy-plane as the signed area +bounded by the curve of the function f(x), the x-axis, and the limits of +integration a and b. But it's not immediately clear how this definition applies +for complex valued functions.</p> + +<p>Consider the following example:</p> + +<div class="precontain"><div class="mathblock"> + <math xmlns="http://www.w3.org/1998/Math/MathML"> + <mrow> + <msubsup> + <mo>∫</mo> + <mn>0</mn> + <mn>1</mn> + </msubsup> + <msup> + <mfenced> + <mn>-1</mn> + </mfenced> + <mi>x</mi> + </msup> + <mi>dx</mi> + </mrow> + </math> +</div></div> + +<p>If the function is graphed on the xy-plane, the real valued outputs are sparse. +Yet an elementary antiderivative exists and the definite integral is well defined.</p> + +<figure> + <img src="/img/minus_one_exp_x_real_values_only.png" + alt="Real values only plot of minus one raised to the x power" + height="400" + width="520"> + <figcaption>Figure 1 - Real values only</figcaption> +</figure> + +<p>In order to plot a meaningful graph that can be used to potentially calculate +the integral as a signed area, some cues are taken from Philip Lloyd's work on +<a href="https://phantomgraphs.weebly.com/" target="_blank">Phantom Graphs</a>. +In that work, an additional z-axis is used to extend the x-axis into a complex +xz-plane, allowing complex inputs to be graphed. For the function considered +here, the z-axis is instead used to extend the y-axis into a complex yz-plane +to allow graphing of complex outputs instead.</p> + +<p>Upon doing so, the following helical graph is obtained:</p> + +<figure> + <img src="/img/minus_one_exp_x_full_plot.png" + alt="Complete three dimensional graph of all values of minux one raised to the x power" + height="400" + width="520"> + <figcaption>Figure 2 - Full graph</figcaption> +</figure> + +<p>The curve is continuous and spirals around the x-axis, intersecting with the +real xy-plane at the points plotted in the initial graph of Figure 1. However +it is still not clear how to represent the area under the curve.</p> + +<p>Observing that complex numbers in cartesian form are composed of a real +part and an imaginary part, it is possible to decompose the function +into real and imaginary components. These are easy to obtain by rotating the +graph above to view the real and imaginary parts as flat planes.</p> + +<table id="component"> + <tr> + <td> + <figure> + <img src="/img/cos_pi_x.png" + alt="Graph of the real component of minus one raised to the power of x" + height="400" + width="520"> + <figcaption>Figure 3 - Real component</figcaption> + </figure> + </td> + <td> + <figure> + <img src="/img/sin_pi_x.png" + alt="Graph of the imaginary component of minus one raised to the power of x" + height="400" + width="520"> + <figcaption>Figure 4 - Imaginary component</figcaption> + </figure> + </td> + </tr> +</table> + +<p>From this it can be seen that the function is a combination of a real valued +cosine and an imaginary valued sine. With the limits of integration under +consideration, the real values disappear and we are left with the following:</p> + +<div class="precontain"><div class="mathblock"> + <table> + <tr> + <td colspan="2"> + <math xmlns="http://www.w3.org/1998/Math/MathML"> + <mrow> + <msubsup> + <mo>∫</mo> + <mn>0</mn> + <mn>1</mn> + </msubsup> + <msup> + <mfenced> + <mn>-1</mn> + </mfenced> + <mi>x</mi> + </msup> + <mi>dx</mi> + </mrow> + </math> + </td> + </tr> + <tr> + <td>=</td> + <td> + <math xmlns="http://www.w3.org/1998/Math/MathML"> + <mrow> + <mi>i</mi> + <msubsup> + <mo>∫</mo> + <mn>0</mn> + <mn>1</mn> + </msubsup> + <mi>sin</mi> + <mfenced> + <mrow> + <mi>π</mi> + <mo>⁢</mo> + <mi>x</mi> + </mrow> + </mfenced> + <mi>dx</mi> + </mrow> + </math> + </td> + </tr> + <tr> + <td>=</td> + <td> + <math xmlns="http://www.w3.org/1998/Math/MathML"> + <mrow> + <mo>-</mo> + <mfrac> + <mi>i</mi> + <mi>π</mi> + </mfrac> + <msubsup> + <menclose notation="right"> + <mrow> + <mi>cos</mi> + <mfenced> + <mrow> + <mi>π</mi> + <mo>⁢</mo> + <mi>x</mi> + </mrow> + </mfenced> + </mrow> + </menclose> + <mn>0</mn> + <mn>1</mn> + </msubsup> + </mrow> + </math> + </td> + </tr> + <tr> + <td>=</td> + <td> + <math xmlns="http://www.w3.org/1998/Math/MathML"> + <mrow> + <mo>-</mo> + <mfrac> + <mi>i</mi> + <mi>π</mi> + </mfrac> + <mfenced> + <mrow> + <mn>-1</mn> + <mo>-</mo> + <mn>1</mn> + </mrow> + </mfenced> + </mrow> + </math> + </td> + </tr> + <tr> + <td>=</td> + <td> + <math xmlns="http://www.w3.org/1998/Math/MathML"> + <mrow> + <mfrac> + <mrow> + <mn>2</mn> + <mi>i</mn> + </mrow> + <mi>π</mi> + </mfrac> + </mrow> + </math> + </td> + </tr> + </table> +</div></div> + +<p>This agrees with the answer obtained by ordinary evaluation of the integral +without considering the graph, so the informal area under the curve definition +still works. Considering the area under the curve using polar coordinates also +works, but requires evaluating a less than pleasant infinite sum and so won't +be considered here.</p> + +<p>The next interesting question is how this relates to the surface area of a +<a href="https://www.mathcurve.com/surfaces.gb/helicoiddroit/helicoiddroit.shtml" target="_blank">right helicoid</a>.</p> + +{% endblock %} + + |