move geometry to geometry2d and add new geometry module (3d)

This commit is contained in:
2019-12-21 12:51:34 +01:00
parent 9319d1bb06
commit 95a289be75
102 changed files with 3771 additions and 9082 deletions

View File

@@ -0,0 +1,205 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>pylib.numerical.integration module &#8212; pylib 2019.12.21 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="pylib.numerical.ode module" href="pylib.numerical.ode.html" />
<link rel="prev" title="pylib.numerical.fit module" href="pylib.numerical.fit.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="module-pylib.numerical.integration">
<span id="pylib-numerical-integration-module"></span><h1>pylib.numerical.integration module<a class="headerlink" href="#module-pylib.numerical.integration" title="Permalink to this headline"></a></h1>
<p>Numerical integration, numerical quadrature.</p>
<p>de: numerische Integration, numerische Quadratur.</p>
<dl class="field-list simple">
<dt class="field-odd">Date</dt>
<dd class="field-odd"><p>2015-10-15</p>
</dd>
</dl>
<span class="target" id="module-integration"></span><dl class="function">
<dt id="pylib.numerical.integration.trapez">
<code class="sig-name descname">trapez</code><span class="sig-paren">(</span><em class="sig-param">f</em>, <em class="sig-param">a=0</em>, <em class="sig-param">b=1</em>, <em class="sig-param">N=10</em>, <em class="sig-param">x=None</em>, <em class="sig-param">verbose=False</em>, <em class="sig-param">save_values=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/numerical/integration.html#trapez"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.numerical.integration.trapez" title="Permalink to this definition"></a></dt>
<dd><p>Integration of <span class="math notranslate nohighlight">\(f(x)\)</span> using the trapezoidal rule
(Simpsons rule, Keplers rule).</p>
<p>de: Trapezregel, Simpsonregel (Thomas Simpson), Keplersche
Fassregel (Johannes Kepler)</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>f</strong> (<em>function</em><em> or </em><em>list</em>) function to integrate.</p></li>
<li><p><strong>a</strong> (<em>float</em>) lower limit of integration (default = 0).</p></li>
<li><p><strong>b</strong> (<em>float</em>) upper limit of integration (default = 1).</p></li>
<li><p><strong>N</strong> (<em>int</em>) specify the number of subintervals.</p></li>
<li><p><strong>x</strong> (<em>list</em>) variable of integration, necessary if f is a list
(default = None).</p></li>
<li><p><strong>verbose</strong> (<em>bool</em>) print information (default = False)</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>the definite integral as approximated by trapezoidal
rule.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
<p>The trapezoidal rule approximates the integral by the area of a
trapezoid with base h=b-a and sides equal to the values of the
integrand at the two end points.</p>
<div class="math notranslate nohighlight">
\[f_n(x) = f(a)+\frac{f(b)-f(a)}{b-a}(x-a)\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}I &amp;= \int\limits_a^b f(x) \,\mathrm{d}x \\
I &amp;\approx \int\limits_a^b f_n(x) \,\mathrm{d}x \\
&amp;= \int\limits_a^b
\left( f(a)+\frac{f(b)-f(a)}{b-a}(x-a) \right)
\mathrm{d}x \\
&amp;= \left.\left( f(a)-a\frac{f(b)-f(a)}{b-a} \right)
x \right\vert_a^b +
\left. \frac{f(b)-f(a)}{b-a} \frac{x^2}{2}
\right\vert_a^b \\
&amp;= \frac{b-a}{2}\left[f(a)+f(b)\right]\end{split}\]</div>
<p>The composite trapezium rule. If the interval is divided into n
segments (not necessarily equal)</p>
<div class="math notranslate nohighlight">
\[a = x_0 \leq x_1 \leq x_2 \leq \ldots \leq x_n = b\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}I &amp;\approx \sum\limits_{i=0}^{n-1} \frac{1}{2} (x_{i+1}-x_i)
\left[f(x_{i+1})+f(x_i)\right] \\\end{split}\]</div>
<p>Special Case (Equaliy spaced base points)</p>
<div class="math notranslate nohighlight">
\[x_{i+1}-x_i = h \quad \forall i\]</div>
<div class="math notranslate nohighlight">
\[I \approx h \left\{ \frac{1}{2} \left[f(x_0)+f(x_n)\right] +
\sum\limits_{i=1}^{n-1} f(x_i) \right\}\]</div>
<p class="rubric">Example</p>
<div class="math notranslate nohighlight">
\[\begin{split}I &amp;= \int\limits_a^b f(x) \,\mathrm{d}x \\
f(x) &amp;= x^2 \\
a &amp;= 0 \\
b &amp;= 1\end{split}\]</div>
<p>analytical solution</p>
<div class="math notranslate nohighlight">
\[I = \int\limits_{0}^{1} x^2 \,\mathrm{d}x
= \left. \frac{1}{3} x^3 \right\vert_0^1
= \frac{1}{3}\]</div>
<p>numerical solution</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="k">lambda</span><span class="p">(</span><span class="n">x</span><span class="p">):</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">trapez</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">0.5</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">trapez</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
<span class="go">0.3350000000000001</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">trapez</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span>
<span class="go">0.33335000000000004</span>
</pre></div>
</div>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="index.html">pylib</a></h1>
<h3>Navigation</h3>
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="modules.html">pylib</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="pylib.html">pylib package</a></li>
</ul>
</li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
<li><a href="modules.html">pylib</a><ul>
<li><a href="pylib.html">pylib package</a><ul>
<li><a href="pylib.numerical.html">pylib.numerical package</a><ul>
<li>Previous: <a href="pylib.numerical.fit.html" title="previous chapter">pylib.numerical.fit module</a></li>
<li>Next: <a href="pylib.numerical.ode.html" title="next chapter">pylib.numerical.ode module</a></li>
</ul></li>
</ul></li>
</ul></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, Daniel Weschke.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/pylib.numerical.integration.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>