Golden spiral: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
en>BattyBot
m fixed CS1 errors: dates & General fixes using AWB (9816)
en>Dicklyon
→‎Approximations of the golden spiral: no period after non-sentence caption
 
Line 1: Line 1:
[[Image:simpsons method illustration.png|thumb|right|Simpson's rule can be derived by approximating the integrand ''f ''(''x'') (in blue) by the quadratic interpolant ''P''(''x'') (in red).]]
The title of the author is Jayson. Invoicing is my occupation. To perform lacross is the factor I love most of all. North Carolina is exactly where we've been residing for years and will by no means move.<br><br>My weblog; [http://www.monsterhuntclips.com/users/RLarson psychic readings]
{{for|Simpson's voting rule|Minimax Condorcet}}
In [[numerical analysis]], '''Simpson's  rule''' is a method for [[numerical integration]], the numerical approximation of [[definite integral]]s. Specifically, it is the following approximation:
 
:<math> \int_{a}^{b} f(x) \, dx \approx \frac{b-a}{6}\left[f(a) + 4f\left(\frac{a+b}{2}\right)+f(b)\right].</math>
 
Simpson's rule also corresponds to the three-point [[Newton-Cotes formulas|Newton-Cotes quadrature rule]].
 
The method is credited to the mathematician [[Thomas Simpson]] (1710–1761) of Leicestershire, England. [[Kepler]] used similar formulas over 100 years prior. In German, the method is sometimes called ''Keplersche Fassregel'' for this reason.
 
Simpson's rule is a staple of scientific data analysis and engineering. It is widely used, for example, by [[Naval architecture|naval architects]] to numerically integrate hull offsets and cross-sectional areas to determine volumes and centroids of ships or [[lifeboat (shipboard)|lifeboats]].<ref>McCall Pate (1918)</ref>
 
==Derivation==
 
Simpson's rule can be derived in various ways.
 
===Quadratic interpolation===
 
One derivation replaces the integrand  <math>f(x)</math> by the [[quadratic polynomial]] (i.e. parabola)<math>P(x)</math> which takes the same values as <math>f(x)</math> at the end points ''a'' and ''b'' and the midpoint ''m'' = (''a''&nbsp;+&nbsp;''b'') / 2. One can use [[Lagrange polynomial|Lagrange polynomial interpolation]] to find an expression for this polynomial,
:<math> P(x) = f(a) \frac{(x-m)(x-b)}{(a-m)(a-b)} + f(m) \frac{(x-a)(x-b)}{(m-a)(m-b)} + f(b) \frac{(x-a)(x-m)}{(b-a)(b-m)}.
</math>
An easy (albeit tedious) calculation shows that
:<math> \int_{a}^{b} P(x) \, dx =\frac{b-a}{6}\left[f(a) + 4f\left(\frac{a+b}{2}\right)+f(b)\right].</math><ref>Atkinson, p. 256; Süli and Mayers, §7.2</ref>
 
This calculation can be carried out more easily if one first observes that (by scaling) there is [[Without loss of generality|no loss of generality]] in assuming that <math>a=-1</math> and <math>b=1</math>.
 
===Averaging the midpoint and the trapezoidal rules===
 
Another derivation constructs Simpson's rule from two simpler approximations: the [[rectangle rule|midpoint rule]]
:<math> M = (b-a) f \left( \frac{a+b}{2} \right) </math>
and the [[trapezoidal rule]]
:<math> T = \tfrac12 (b-a) (f(a)+f(b)). </math>
The errors in these approximations are
:<math> -\tfrac1{ 24} (b-a)^3 f''(a) + O((b-a)^4) \quad\text{and}\quad \tfrac1{12} (b-a)^3 f''(a) + O((b-a)^4), </math>
respectively, where <math> O((b-a)^4) </math> denotes a term asymptotically proportional to <math> (b-a)^4 </math>. The two <math> O((b-a)^4) </math> terms are not equal; see [[Big O notation]] for more details. It follows from the above formulas for the errors of the midpoint and trapezoidal rule that the leading error term vanishes if we take the [[weighted average]]
:<math> \frac{2M+T}{3}. </math>
This weighted average is exactly Simpson's rule.
 
Using another approximation (for example, the trapezoidal rule with twice as many points), it is possible to take a suitable weighted average and eliminate another error term.  This is [[Romberg's method]].
 
===Undetermined coefficients===
 
The third derivation starts from the ''[[ansatz]]''
 
:<math> \frac{1}{b-a} \int_{a}^{b} f(x) \, dx \approx \alpha f(a) + \beta f\left(\frac{a+b}{2}\right) + \gamma f(b).</math>
 
The coefficients α, β and γ can be fixed by requiring that this approximation be exact for all quadratic polynomials. This yields Simpson's rule.
 
==Error==
 
The error in approximating an integral by Simpson's rule is
 
:<math> \frac{1}{90} \left(\frac{b-a}{2}\right)^5 \left|f^{(4)}(\xi)\right|, </math>
 
where <math>\xi</math> is some number between <math>a</math> and <math>b</math>.<ref>Atkinson, equation (5.1.15); Süli and Mayers, Theorem 7.2</ref>
 
The error is asymptotically proportional to <math>(b-a)^5</math>. However, the above derivations suggest an error proportional to <math>(b-a)^4</math>. Simpson's rule gains an extra order because the points at which the integrand is evaluated are distributed symmetrically in the interval [''a'', ''b''].
 
Since the error term is proportional to the fourth derivative of ''f'' at <math>\xi</math>, this shows that Simpson's rule provides exact results for any polynomial ''f'' of degree three or less, since the fourth derivative of such a polynomial is zero at all points.
 
==Composite Simpson's rule==
 
If the interval of integration <math>[a, b]</math> is in some sense "small", then Simpson's rule will provide an adequate approximation to the exact integral.  By small, what we really mean is that the function being integrated is relatively smooth over the interval <math>[a, b]</math>.  For such a function, a smooth quadratic interpolant like the one used in Simpson's rule will give good results.
 
However, it is often the case that the function we are trying to integrate is not smooth over the interval.  Typically, this means that either the function is highly oscillatory, or it lacks derivatives at certain points.  In these cases, Simpson's rule may give very poor results.  One common way of handling this problem is by breaking up the interval <math>[a, b]</math> into a number of small subintervals.  Simpson's rule is then applied to each subinterval, with the results being summed to produce an approximation for the integral over the entire interval.  This sort of approach is termed the ''composite Simpson's rule''.
 
Suppose that the interval <math>[a, b]</math> is split up in <math>n</math> subintervals, with <math>n</math> an even number. Then, the composite Simpson's rule is given by
 
:<math>\int_a^b f(x) \, dx\approx
\frac{h}{3}\bigg[f(x_0)+2\sum_{j=1}^{n/2-1}f(x_{2j})+
4\sum_{j=1}^{n/2}f(x_{2j-1})+f(x_n)
\bigg],</math>
 
where <math>x_j=a+jh</math> for <math>j=0, 1, ..., n-1, n</math> with <math>h=(b-a)/n</math>; in particular, <math>x_0=a</math> and <math>x_n=b</math>. The above formula can also be written as
 
:<math>\int_a^b f(x) \, dx\approx
\frac{h}{3}\bigg[f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+2f(x_4)+\cdots+4f(x_{n-1})+f(x_n)\bigg].</math>
 
The error committed by the composite Simpson's rule is bounded (in absolute value) by
 
:<math>\frac{h^4}{180}(b-a) \max_{\xi\in[a,b]} |f^{(4)}(\xi)|,</math>
 
where <math>h</math> is the "step length", given by <math>h=(b-a)/n.</math><ref>Atkinson, pp. 257+258; Süli and Mayers, §7.5</ref>
 
This formulation splits the interval <math>[a,b]</math> in subintervals of equal length. In practice, it is often advantageous to use subintervals of different lengths, and concentrate the efforts on the places where the integrand is less well-behaved. This leads to the [[adaptive Simpson's method]].
 
==Alternative extended Simpson's rule==
 
This is another formulation of a composite Simpson's rule: instead of applying Simpson's rule to disjoint segments of the integral to be approximated, Simpson's rule is applied to overlapping segments, yielding:<ref>Press (1989), p. 122</ref>
 
:<math>
\int_a^b f(x) \, dx\approx
\frac{h}{48}\bigg[17f(x_0)+59f(x_1)+43f(x_2)+49f(x_3)+48 \sum_{i=4}^{n-4} f(x_i)+49f(x_{n-3})+43f(x_{n-2})+59f(x_{n-1})+17f(x_n)\bigg].
</math>
 
The formula above is obtained by combining the original composite Simpson's rule with the one consisting in using Simpson's 3/8 rule in the extreme subintervals and the standard 3-point rule in the remaining subintervals. The result is then obtained by taking the mean of the two formulas.
 
==Simpson's 3/8 rule==
 
Simpson's 3/8 rule is another method for numerical integration proposed by Thomas Simpson. It is based upon a cubic interpolation rather than a quadratic interpolation. Simpson's 3/8 rule is as follows:
:<math> \int_{a}^{b} f(x) \, dx \approx \frac{3h}{8}\left[f(a) + 3f\left(\frac{2a+b}{3}\right) + 3f\left(\frac{a+2b}{3}\right) + f(b)\right]
= \frac{(b-a)}{8}\left[f(a) + 3f\left(\frac{2a+b}{3}\right) + 3f\left(\frac{a+2b}{3}\right) + f(b)\right]\, ,</math>
where ''b'' - ''a'' = 3''h''. The error of this method is:
:<math> \left|\frac{(b-a)^5}{6480} f^{(4)}(\xi)\right|, </math>
where <math>\xi</math> is some number between <math>a</math> and <math>b</math>. Thus, the 3/8 rule is about twice as accurate as the standard method, but it uses one more function value. A composite 3/8 rule also exists, similarly as above.<ref>Matthews (2004)</ref>
 
A further generalization of this concept for interpolation with arbitrary degree polynomials are the [[Newton–Cotes formulas]].
 
==Simpson's 3/8 rule (for n intervals)==
Defining,
 
:<math> h=(b-a)/n, \quad \quad x_i = a + ih,</math>
 
we have
 
:<math> \int_{a}^{b} f(x) \, dx \approx \frac{3h}{8}\left[f(x_0) + 3f(x_1) + 3f(x_2)
+ 2f(x_3) + 3f(x_4) + 3f(x_5) + 2f(x_6) + ... + f(x_n)\right] .</math>
 
Note, we can only use this if <math>n</math> is a multiple of three.
 
==Sample implementation==
 
An implementation of the composite Simpson's rule in [[Python (programming language)|Python 2]]:
 
<source lang="python">
#!/usr/bin/env python2
from __future__ import division
 
def simpson(f, a, b, n):
    """Approximates the definite integral of f from a to b by
    the composite Simpson's rule, using n subintervals"""
    h = (b - a) / n
    s = f(a) + f(b)
 
    for i in range(1, n, 2):
        s += 4 * f(a + i * h)
    for i in range(2, n-1, 2):
        s += 2 * f(a + i * h)
 
    return s * h / 3
 
print simpson(lambda x:x**9, 0.0, 10.0, 100000)
# displays 1000000000.0
</source>
 
==See also==
 
* [[Gaussian quadrature]]
* [[Rectangle method]]
* [[Trapezoidal rule]]
* [[Boole's rule]]
 
==Notes==
 
{{Reflist}}
 
==References==
 
* {{Cite book| author=Atkinson, Kendall E. | title=An Introduction to Numerical Analysis | edition=2nd | publisher=John Wiley & Sons | year=1989 | isbn=0-471-50023-2}}
* {{Cite book| author=Burden, Richard L. and Faires, J. Douglas | title=Numerical Analysis | edition=7th | publisher=Brooks/Cole | year=2000 | isbn=0-534-38216-9}}
* {{cite book | title = The naval artificer's manual: (The naval artificer's handbook revised) text, questions and general information for deck  | author = McCall Pate | publisher = United States. Bureau of Reconstruction and Repair | year = 1918 | page = 198 | url = http://books.google.com/books?id=bQc9AAAAYAAJ&pg=PA198 }}
* {{Cite web| author=Matthews, John H. | url = http://math.fullerton.edu/mathews/n2003/Simpson38RuleMod.html | title = Simpson's 3/8 Rule for Numerical Integration | work = Numerical Analysis - Numerical Methods Project | publisher = California State University, Fullerton | accessdate = 11 November 2008 | year = 2004}}
* {{Cite book| title = Numerical Recipes in Pascal: The Art of Scientific Computing | author = Press, William H., Brian P. Flannery, William T. Vetterling, and Saul A. Teukolsky | publisher = Cambridge University Press | year = 1989 | isbn = 0-521-37516-9 | url = http://books.google.com/?id=bh5w6E-M-PUC&pg=PA122&dq=extended-simpson%27s-rule }}
* {{Cite book| author=Süli, Endre and Mayers, David | title=An Introduction to Numerical Analysis | publisher=Cambridge University Press | year=2003 | isbn=0-521-00794-1}}
* {{Cite web| last1=Kaw | first1=Autar | last2=Kalu | first2=Egwu | year=2008 | title=Numerical Methods with Applications | edition=1st | publisher=[http://www.autarkaw.com] }}.
* {{Cite web| author=Weisstein, Eric W. | url = http://mathworld.wolfram.com/Newton-CotesFormulas.html | title = Newton-Cotes Formulas | work = MathWorld--A Wolfram Web Resource. | publisher = MathWorld | accessdate = 2 August 2010 | year = 2010}}
 
==External links==
* {{springer|title=Simpson formula|id=p/s085450}}
* {{mathworld|urlname=SimpsonsRule|title=Simpson's Rule}}
* [http://math.fullerton.edu/mathews/n2003/SimpsonsRuleMod.html Simpson's Rule for Numerical Integration]
* [http://civilengineeringarticles.blogspot.in/2011/07/earthwork-volume-using-simpsons-rule.html Application of Simpson's Rule &mdash; Earthwork Excavation] (Note: The formula described in this page is correct but there are errors in the calculation which should give a result of 569m3 and not 623m3 as stated)
* [http://numericalmethods.eng.usf.edu/topics/simpsons_13rd_rule.html Simpson's 1/3rd rule of integration &mdash; Notes, PPT, Mathcad, Matlab, Mathematica, Maple] at [http://numericalmethods.eng.usf.edu Numerical Methods for STEM undergraduate]
* A detailed description of a computer implementation is described by Dorai Sitaram in ''Teach Yourself [[Scheme (programming language)|Scheme]] in Fixnum Days'', [http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-22.html#node_chap_C Appendix C]
* [http://hamsoft-hq.com/toys/junk.php?id=4 C Language Program to Implement Simpson's Rule]
 
{{PlanetMath attribution|id=6518|title=Code for Simpson's rule}}
 
{{Use dmy dates|date=September 2010}}
{{DEFAULTSORT:Simpson's Rule}}
[[Category:Integral calculus]]
[[Category:Numerical integration (quadrature)]]
[[Category:Numerical analysis]]
[[Category:Articles with example Python code]]

Latest revision as of 09:46, 30 December 2014

The title of the author is Jayson. Invoicing is my occupation. To perform lacross is the factor I love most of all. North Carolina is exactly where we've been residing for years and will by no means move.

My weblog; psychic readings