Main Page: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{About|numerical rounding|lip-rounding in phonetics|Labialisation|other uses|Rounding (disambiguation)}}
[[Image:Integral as region under curve.svg|thumb|right|Numerical integration consists of finding numerical approximations for the value <math>S</math>]]
{{Cleanup|reason=This article has duplicate content and attempts to describe a large subject in a single page|date=January 2013}}
In [[numerical analysis]], '''numerical integration''' constitutes a broad family of algorithms for calculating the numerical value of a definite [[integral]], and by extension, the term is also sometimes used to describe the [[numerical ordinary differential equations|numerical solution of differential equations]]. This article focuses on calculation of definite integrals. The term '''numerical quadrature''' (often abbreviated to [[Quadrature (mathematics)|''quadrature'']]) is more or less a synonym for ''numerical integration'', especially as applied to one-dimensional integrals. Numerical integration over more than one dimension is sometimes described as '''cubature''',<ref>{{MathWorld | urlname=Cubature | title=Cubature }}</ref> although the meaning of ''quadrature'' is understood for higher dimensional integration as well.
'''Rounding''' a [[numerical value]] means replacing it by another value that is approximately equal but has a shorter, simpler, or more explicit representation; for example, replacing £23.4476 with £23.45, or the fraction 312/937 with 1/3, or the expression √2 with 1.414.


Rounding is often done to obtain a value that is easier to [[report]] and [[communicate]] than the original. Rounding can also be important to avoid [[overprecision|misleadingly precise]] reporting of a computed number, [[measurement]] or [[estimate]]; for example, a quantity that was computed as 123,456 but is known to be [[Accuracy and precision|accurate]] only to within a few hundred units is better stated as "about 123,500."
The basic problem considered by numerical integration is to compute an approximate solution to a definite integral:


On the other hand, rounding of exact numbers will introduce some [[round-off error]] in the reported result.  Rounding is almost unavoidable when reporting many computations — especially when dividing two numbers in [[integer]] or [[fixed-point arithmetic]]; when computing mathematical functions such as [[square root]]s, [[logarithm]]s, and [[sine]]s; or when using a [[floating point]] representation with a fixed number of [[significant digit]]s.  In a sequence of calculations, these rounding errors generally accumulate, and in certain [[ill-conditioned]] cases they may make the result meaningless.
:<math>\int_a^b\! f(x)\, dx.</math>


Accurate rounding of [[transcendental function|transcendental mathematical functions]] is difficult because the number of extra digits that need to be calculated to resolve whether to round up or down cannot be known in advance. This problem is known as "the table-maker's dilemma".
If {{math|''f(x)''}} is a smooth well-behaved function, integrated over a small number of dimensions and the limits of integration are bounded, there are many methods of approximating the integral with arbitrary precision.


Rounding has many similarities to the [[quantization (signal processing)|quantization]] that occurs when [[physical quantity|physical quantities]] must be encoded by numbers or [[digital signal]]s.
==Reasons for numerical integration==


A wavy [[equals sign]] (<big>'''[[≈]]'''</big>) is sometimes used to indicate rounding of exact numbers. For example: 9.98 ≈ 10.
There are several reasons for carrying out numerical integration.
The integrand ''f(x)'' may be known only at certain points,
== Types of rounding ==
such as obtained by [[sampling (statistics)|sampling]].
Typical rounding problems are
Some [[embedded systems]] and other computer applications may need numerical integration for this reason.
* approximating an irrational number by a fraction, e.g., [[pi|π]] by 22/7;
* approximating a fraction with periodic decimal expansion by a finite decimal fraction, e.g., 5/3 by 1.6667;
* replacing a [[rational number]] by a fraction with smaller numerator and denominator, e.g., 3122/9417 by 1/3;
* replacing a fractional [[decimal number]] by one with fewer digits, e.g., 2.1784 dollars by 2.18 dollars;
* replacing a decimal [[integer]] by an integer with more trailing zeros, e.g., 23,217 people by 23,200 people; or, in general,
* replacing a value by a multiple of a specified amount, e.g., 48.2 seconds by 45 seconds (a multiple of 15 s).


== Rounding to a specified increment ==
A formula for the integrand may be known, but it may be difficult or impossible to find an [[antiderivative]] which is an [[elementary function]]. An example of such an integrand is ''f(x)'' = exp(−''x''<sup>''2''</sup>), the antiderivative of which (the [[error function]], times a constant) cannot be written in [[elementary form]].
The most common type of rounding is to round to an integer; or, more generally, to an integer multiple of some increment — such as rounding to whole tenths of seconds, hundredths of a dollar, to whole multiples of 1/2 or 1/8&nbsp;inch, to whole dozens or thousands, etc.


In general, rounding a number ''x'' to a multiple of some specified increment ''m'' entails the following steps:
It may be possible to find an antiderivative symbolically, but it may be easier to compute a numerical approximation than to compute the antiderivative. That may be the case if the antiderivative is given as an infinite series or product, or if its evaluation requires a [[special function]] which is not available.


#Divide ''x'' by ''m'', let the result be ''y'';
==Methods for one-dimensional integrals==
#Round ''y'' to an integer value, call it ''q'';
#Multiply ''q'' by ''m'' to obtain the rounded value ''z''.
:: <math>z = \mathrm{round}(x, m) = \mathrm{round}(x / m) \cdot m\,</math>


For example, rounding ''x''&nbsp;=&nbsp;2.1784 dollars to whole cents (i.e., to a multiple of 0.01) entails computing ''y''&nbsp;=&nbsp;''x''/''m''&nbsp;=&nbsp;2.1784/0.01&nbsp;=&nbsp;217.84, then rounding ''y'' to the integer ''q''&nbsp;=&nbsp;218, and finally computing ''z''&nbsp;=&nbsp;''q''×''m''&nbsp;=&nbsp;218×0.01&nbsp;=&nbsp;2.18.
Numerical integration methods can generally be described as combining evaluations of the integrand to get an approximation to the integral. The integrand is evaluated at a finite set of points called '''integration points''' and a weighted sum of these values is used to approximate the integral. The integration points and weights depend on the specific method used and the accuracy required from the approximation.


When rounding to a predetermined number of [[significant figure|significant digits]], the increment ''m'' depends on the magnitude of the number to be rounded (or of the rounded result).
An important part of the analysis of any numerical integration method is to study the behavior of the approximation error as a function of the number of integrand evaluations.
A method which yields a small error for a small number of evaluations is usually considered superior.
Reducing the number of evaluations of the integrand reduces the number of arithmetic operations involved,
and therefore reduces the total [[round-off error]].
Also,
each evaluation takes time, and the integrand may be arbitrarily complicated.


The increment ''m'' is normally a finite fraction in whatever [[number system]] that is used to represent the numbers.  For display to humans, that  usually means the [[decimal number|decimal number system]] (that is, ''m'' is an integer times a [[power (mathematics)|power]] of 10, like 1/1000 or 25/100). For intermediate values stored in digital computers, it often means the [[binary number|binary number system]] (''m'' is an integer times a power of 2).
A 'brute force' kind of numerical integration can be done, if the integrand is reasonably well-behaved (i.e. [[piecewise]] [[continuous function|continuous]] and of [[bounded variation]]), by evaluating the integrand with very small increments.


The abstract single-argument "round()" function that returns an integer from an arbitrary real value has at least a dozen distinct concrete definitions presented in the [[#Rounding to integer|rounding to integer]] section. The abstract two-argument "round()" function is formally defined here, but in many cases it is used with the implicit value ''m''&nbsp;=&nbsp;1 for the increment and then reduces to the equivalent abstract single-argument function, with also the same dozen distinct concrete definitions.
=== Quadrature rules based on interpolating functions ===


== Rounding to integer ==
A large class of quadrature rules can be derived by constructing  [[interpolation|interpolating]] functions which are easy to integrate. Typically these interpolating functions are [[polynomial]]s.
The most basic form of rounding is to replace an arbitrary number by an integer. All the following rounding modes are concrete implementations of the abstract single-argument "round()" function presented and used in the previous sections.


There are many ways of rounding a number ''y'' to an integer ''q''.  The most common ones are
[[Image:Integration rectangle.svg|right|frame|Illustration of the rectangle rule.]]
* '''round down''' (or take the '''[[floor and ceiling functions|floor]]''', or '''round towards minus infinity'''): ''q'' is the largest integer that does not exceed ''y''.
The simplest method of this type is to let the interpolating function be a constant function (a polynomial of degree zero) which passes through the point ((''a''+''b'')/2, ''f''((''a''+''b'')/2)). This is called the ''midpoint rule'' or ''[[rectangle method|rectangle rule]]''.
*: <math>q = \mathrm{floor}(y) = \left\lfloor y \right\rfloor = -\left\lceil -y \right\rceil\,</math>
* '''round up''' (or take the '''[[floor and ceiling functions|ceiling]]''',  or '''round towards plus infinity'''):  ''q'' is the smallest integer that is not less than ''y''.
*: <math>q = \mathrm{ceil}(y) = \left\lceil y \right\rceil = -\left\lfloor -y \right\rfloor\,</math>
* '''round towards zero''' (or '''[[truncation|truncate]]''', or '''round away from infinity'''): ''q'' is the integer part of ''y'', without its fraction digits.
*: <math>q = \mathrm{truncate}(y) = \sgn(y) \left\lfloor \left| y \right| \right\rfloor = -\sgn(y) \left\lceil -\left| y \right| \right\rceil\,</math>
* '''round away from zero''' (or '''round towards infinity'''): if ''y'' is an integer, ''q'' is ''y''; else ''q'' is the integer that is closest to 0 and is such that ''y'' is between 0 and ''q''.
*: <math>q = \sgn(y) \left\lceil \left| y \right| \right\rceil = -\sgn(y) \left\lfloor -\left| y \right| \right\rfloor\,</math>
* '''round to nearest''': ''q'' is the integer that is closest to ''y'' (see below for tie-breaking rules).


The first four methods are called '''directed rounding''', as the displacements from the original number ''y'' to the rounded value ''q'' are all directed towards or away from the same limiting value (0, [[Extended real number line|+∞]], or −∞).
:<math>\int_a^b f(x)\,dx \approx (b-a) \, f\left(\frac{a+b}{2}\right).</math>


If ''y'' is positive, round-down is the same as round-towards-zero, and round-up is the same as round-away-from-zero.  If ''y'' is negative, round-down is the same as round-away-from-zero, and round-up is the same as round-towards-zero. In any case, if ''y'' is integer, ''q'' is just ''y''. The following table illustrates these rounding methods:
[[Image:Integration trapezoid.svg|right|frame|Illustration of the trapezoidal rule. ]]
The interpolating function may be an [[affine function]] (a polynomial of degree 1)
which passes through the points (''a'', ''f''(''a'')) and (''b'', ''f''(''b'')).
This is called the ''[[trapezoidal rule]]''.


{|class="wikitable" style="text-align:center"
:<math>\int_a^b f(x)\,dx \approx (b-a) \, \frac{f(a) + f(b)}{2}.</math>
|-
!width="25%"| ''y''
!width="15%"| round<br /> down<br /> <small>(towards −∞)</small>
!width="15%"| round<br /> up<br /> <small>(towards +)</small>
!width="15%"| round<br /> towards<br /> zero
!width="15%"| round<br /> away from<br /> zero
!width="15%"| round<br /> to<br /> nearest
|-
| +23.67 || +23 || +24 || +23 || +24 || +24
|-
| +23.50 || +23 || +24 || +23 || +24 || +24
|-
| +23.35 || +23 || +24 || +23 || +24 || +23
|-
| +23.00 || +23 || +23 || +23 || +23 || +23
|-
| 0 || 0 || 0 || 0 || 0 || 0
|-
| −23.00 || −23 || −23 || −23 || −23 || −23
|-
| −23.35 || −24 || −23 || −23 || −24 || −23
|-
| −23.50 || −24 || −23 || −23 || −24 || −24
|-
| −23.67 || −24 || −23 || −23 || −24 || −24
|}


Where many calculations are done in sequence, the choice of rounding method can have a very significant effect on the result. A famous instance involved a new [[stock index|index]] set up by the [[Vancouver Stock Exchange]] in 1982. It was initially set at 1000.000 (three decimal places of accuracy), and after 22 months had fallen to about 520 — whereas [[stock price]]s had generally increased in the period. The problem was caused by the index being recalculated thousands of times daily, and always being rounded down to 3 decimal places, in such a way that the rounding errors accumulated. Recalculating with better rounding gave an index value of 1098.892 at the end of the same period.<ref>{{cite book|title=Accuracy and stability of numerical algorithms|author=Nicholas J. Higham|page=54|isbn=978-0-89871-521-7|year=2002}}</ref>
[[Image:Integration simpson.png|right|frame|Illustration of Simpson's rule.]]
For either one of these rules, we can make a more accurate approximation by breaking  up the interval [''a'', ''b''] into some number ''n'' of subintervals, computing an  approximation for each subinterval, then adding up all the results. This is called a ''composite rule'', ''extended rule'', or ''iterated rule''. For example, the composite trapezoidal rule can be stated as


== Tie-breaking ==
:<math>\int_a^b f(x)\,dx \approx \frac{b-a}{n} \left( {f(a) \over 2} + \sum_{k=1}^{n-1} f \left( a+k \frac{b-a}{n} \right) + {f(b) \over 2} \right)</math>
Rounding a number ''y'' to the nearest integer requires some tie-breaking rule for those cases when ''y'' is exactly half-way between two integers — that is, when the fraction part of ''y'' is exactly 0.5.


=== Round half up ===
where the subintervals have the form [''k'' ''h'', (''k''+1) ''h''], with ''h'' = (''b''−''a'')/''n'' and ''k'' = 0, 1, 2, ..., ''n''−1.
The following  tie-breaking rule, called '''round half up''' (or '''round half towards positive infinity'''), is widely used in many disciplines. That is, half-way values ''y'' are always rounded up.


* If the fraction of ''y'' is exactly 0.5, then ''q'' = ''y'' + 0.5.
Interpolation with polynomials evaluated at equally spaced points in [''a'', ''b''] yields the [[Newton–Cotes formulas]], of which the rectangle rule and the trapezoidal rule are examples. [[Simpson's rule]], which is based on a polynomial of order 2, is also a Newton–Cotes formula.
*: <math>q = \left\lfloor y + 0.5 \right\rfloor = -\left\lceil -y - 0.5 \right\rceil</math>


For example, by this rule the value 23.5 gets rounded to 24, but −23.5 gets rounded to −23.
Quadrature rules with equally spaced points have the very convenient property of <em>nesting</em>.  The corresponding rule with each interval subdivided includes all the current points, so those integrand values can be re-used.


However, some programming languages (such as Java) define ''HALF_UP'' as ''round half away from zero''.<ref>{{cite web|title=java.math.RoundingMode|url=http://docs.oracle.com/javase/8/docs/api/java/math/RoundingMode.html#HALF_UP|publisher=Oracle}}</ref>
If we allow the intervals between interpolation points to vary, we find another group of quadrature formulas, such as the [[Gaussian quadrature]] formulas. A Gaussian  quadrature rule is typically more accurate than a Newton–Cotes rule which requires the same number of function evaluations, if the integrand is [[Smooth function|smooth]] (i.e., if it is sufficiently differentiable). Other quadrature methods with varying intervals include [[Clenshaw–Curtis quadrature]] (also called Fejér quadrature) methods, which do nest.


If it were not for the 0.5 fractions, the round-off errors introduced by the round to nearest method would be symmetric: for every fraction that gets rounded up (such as 0.268), there is a complementary fraction (namely, 0.732) that gets rounded down by the same amount. When rounding a large set of numbers with [[random]] fractional parts, these rounding errors would statistically compensate each other, and the [[expectation (mathematics)|expected]] (average) value of the rounded numbers would be equal to the expected value of the original numbers.
Gaussian quadrature rules do not nest, but the related [[Gauss–Kronrod quadrature formula]]s do.


However, the ''round half up'' tie-breaking rule is not symmetric, as the fractions that are exactly 0.5 always get rounded up. This asymmetry introduces a positive bias in the round-off errors. For example, if the fraction of ''y'' consists of three random decimal digits, then the expected value of ''q'' will be 0.0005 higher than the expected value of ''y''. For this reason, round-to-nearest with the ''round half up'' rule is also (ambiguously) known as '''asymmetric rounding'''.
=== Adaptive algorithms ===
{{details|Adaptive quadrature}}


One reason for rounding up at 0.5 is that for positive decimals, only the first figure after the decimal point needs be examined. For example, when looking at 17.5000…, the "5" alone determines that the number should be rounded up, to 18 in this case. This is not true for negative decimals, such as −17.5000…, where all the fractional figures of the value need to be examined to determine if it should round to −17, if it were −17.5000000, or to −18, if it were −17.5000001 or smaller.
If ''f(x)'' does not have many derivatives at all points, or if the derivatives become large, then Gaussian quadrature is often insufficient. In this case, an algorithm similar to the following will perform better:


=== Round half down ===
One may also use '''round half down''' (or '''round half towards negative infinity''') as opposed to the more common ''round half up''.


* If the fraction of ''y'' is exactly 0.5, then ''q'' = ''y'' − 0.5.
<source lang=python>
*: <math>q = \left\lceil y - 0.5 \right\rceil = -\left\lfloor -y + 0.5 \right\rfloor\,</math>
def calculate_definite_integral_of_f(f, initial_step_size):
    '''
    This algorithm calculates the definite integral of a function
    from 0 to 1, adaptively, by choosing smaller steps near
    problematic points.
    '''
    x = 0.0
    h = initial_step_size
    accumulator = 0.0
    while x < 1.0:
        if x + h > 1.0:
            h = 1.0 - x
        quad_this_step =
        if error_too_big_in_quadrature_of_over_range(f, [x,x+h]):
            h = make_h_smaller(h)
        else:
            accumulator += quadrature_of_f_over_range(f, [x,x+h])
            x += h
            if error_too_small_in_quadrature_of_over_range(f, [x,x+h]):
                h = make_h_larger(h) # Avoid wasting time on tiny steps.
    return accumulator
</source>


For example, 23.5 gets rounded to 23, and −23.5 gets rounded to −24.
Some details of the algorithm require careful thought. For many cases, estimating the error from quadrature over an interval for a function ''f''(''x'') isn't obvious. One popular solution is to use two different rules of quadrature, and use their difference as an estimate of the error from quadrature. The other problem is deciding what "too large" or "very small" signify. A <em>local</em> criterion for "too large" is that the quadrature error should not be larger than ''t''&nbsp;&middot;&nbsp;''h'' where ''t'', a real number, is the tolerance we wish to set for global error. Then again, if ''h'' is already tiny, it may not be worthwhile to make it even smaller even if the quadrature error is apparently large. A <em>global</em> criterion is that the sum of errors on all the intervals should be less than&nbsp;''t''.  This type of error analysis is usually called "a posteriori" since we compute the error after having computed the approximation.


The ''round half down'' tie-breaking rule is not symmetric, as the fractions that are exactly 0.5 always get rounded down. This asymmetry introduces a negative bias in the roundoff errors. For example, if the fraction of ''y'' consists of three random decimal digits, then the expected value of ''q'' will be 0.0005 lower than the expected value of ''y''. For this reason, round-to-nearest with the ''round half down'' rule is also (ambiguously) known as '''asymmetric rounding'''.
Heuristics for adaptive quadrature are discussed by Forsythe et al. (Section 5.4).


=== Round half away from zero ===
=== Extrapolation methods ===
The other tie-breaking method commonly taught and used is the '''round half away from zero''' (or '''round half towards infinity'''), namely:


* If the fraction of ''y'' is exactly 0.5, then ''q'' = ''y'' + 0.5 if ''y'' is positive, and ''q'' = ''y'' − 0.5 if ''y'' is negative.
The accuracy of a quadrature rule of the Newton-Cotes type is generally a function of the number of evaluation points.
*: <math>q = \sgn(y) \left\lfloor \left| y \right| + 0.5 \right\rfloor = -\sgn(y) \left\lceil -\left| y \right| - 0.5 \right\rceil \,</math>
The result is usually more accurate as number of evaluation points increases,
or, equivalently, as the width of the step size between the points decreases.
It is natural to ask what the result would be if the step size were allowed to approach zero.
This can be answered by extrapolating the result from two or more nonzero step sizes, using [[series acceleration]] methods such as [[Richardson extrapolation]].
The extrapolation function may be a [[polynomial]] or [[rational function]].
Extrapolation methods are described in more detail by Stoer and Bulirsch (Section 3.4) and are implemented in many of the routines in the [[QUADPACK]] library.


For example, 23.5 gets rounded to 24, and −23.5 gets rounded to −24.
=== Conservative (a priori) error estimation ===


This method treats positive and negative values symmetrically, and therefore is free of overall bias if the original numbers are positive or negative with equal probability.
Let ''f'' have a bounded first derivative over [''a'',''b'']. The [[mean value theorem]] for ''f'', where ''x''&nbsp;<&nbsp;''b'', gives


It is often used for currency conversions and price roundings (when the amount is first converted into the smallest significant subdivision of the currency, such as cents of a euro) as it is easy to explain by just considering the first fractional digit, independently of supplementary precision digits or sign of the amount (for strict equivalence between the paying and recipient of the amount).
: <math>(x - a) f'(y_x) = f(x) - f(a)\,</math>


=== Round half towards zero ===
for some ''y<sub>x</sub>'' in [''a'',''x''] depending on ''x''. If we integrate in ''x'' from ''a'' to ''b'' on both sides and take the absolute values, we obtain
One may also '''round half towards zero''' (or '''round half away from infinity''') as opposed to the conventional ''round half away from zero''.


* If the fraction of ''y'' is exactly 0.5, then ''q'' = ''y'' − 0.5 if ''y'' is positive, and ''q'' = ''y'' + 0.5 if ''y'' is negative.
: <math>\left| \int_a^b f(x)\,dx - (b - a) f(a) \right|
*: <math>q = \sgn(y) \left\lceil \left| y \right| - 0.5 \right\rceil = -\sgn(y) \left\lfloor -\left| y \right| + 0.5 \right\rfloor \,</math>
  = \left| \int_a^b (x - a) f'(y_x)\, dx \right|</math>


For example, 23.5 gets rounded to 23, and −23.5  gets rounded to −23.
We can further approximate the integral on the right-hand side by bringing the absolute value into the integrand, and replacing the term in ''f' '' by an upper bound:


This method also treats positive and negative values symmetrically, and therefore is free of overall bias if the original numbers are positive or negative with equal probability.
: <math>\left| \int_a^b f(x)\,dx - (b - a) f(a) \right| \leq {(b - a)^2 \over 2} \sup_{a \leq x \leq b} \left| f'(x) \right|</math> (**)


=== Round half to even ===
(See [[supremum]].) Hence, if we approximate the integral ∫<sub>''a''</sub><sup>''b''</sup>&nbsp;''f''(''x'')&nbsp;d''x'' by the quadrature rule (''b''&nbsp;−&nbsp;''a'')''f''(''a'') our error is no greater than the right hand side of (**). We can convert this into an error analysis for the Riemann sum (*), giving an upper bound of
A tie-breaking rule that is less biased is '''round half to even''', namely:


* If the fraction of ''y'' is 0.5, then ''q'' is the ''even'' integer nearest to ''y''.
: <math>{n^{-1} \over 2} \sup_{0 \leq x \leq 1} \left| f'(x) \right|</math>


Thus, for example, +23.5 becomes +24, as does +24.5; while −23.5 becomes −24, as does −24.5.
for the [[error term]] of that particular approximation. (Note that this is precisely the error we calculated for the example <math>f(x) = x</math>.) Using more derivatives, and by tweaking the quadrature, we can do a similar error analysis using a [[Taylor series]] (using a partial sum with remainder term) for ''f''. This error analysis gives a strict upper bound on the error, if the derivatives of ''f'' are available.


This method treats positive and negative values symmetrically, and is therefore free of sign bias. More importantly, for reasonable distributions of ''y'' values, the expected (average) value of the rounded numbers is the same as that of the original numbers. However, this rule will introduce a towards-zero bias when {{nowrap|y − 0.5}} is even, and a towards-infinity bias for when it is odd.
This integration method can be combined with [[interval arithmetic]] to produce [[computer proof]]s and ''verified'' calculations.


This variant of the round-to-nearest method is also called '''unbiased rounding''', '''convergent rounding''', '''statistician's rounding''', '''Dutch rounding''', '''Gaussian rounding''', '''odd-even rounding''',<ref>[http://mscweb.gsfc.nasa.gov/543web/files/GSFC-X-673-64-1F.pdf Engineering Drafting Standards Manual] (NASA), X-673-64-1F, p90</ref> '''bankers' rounding''', or '''broken rounding'''.
=== Integrals over infinite intervals ===


This is the default rounding mode used in [[IEEE floating point|IEEE 754]] computing functions and operators.
==== Infinite intervals ====
One way to calculate an integral over infinite interval,


=== Round half to odd ===
:<math>
A similar tie-breaking rule is '''round half to odd''':
\int_{-\infty}^{+\infty}f(x) \, dx,
</math>


* If the fraction of ''y'' is 0.5, then ''q'' is the ''odd'' integer nearest to ''y''.
is to transform it into an integral over a finite interval by any one of several possible changes of variables, for example:


Thus, for example, +23.5 becomes +23, as does +22.5; while −23.5 becomes −23, as does −22.5.
:<math>
\int_{-\infty}^{+\infty} f(x) \, dx = \int_{-1}^{+1} f\left( \frac{t}{1-t^2} \right) \frac{1+t^2}{(1-t^2)^2} \, dt,
</math>


This method also treats positive and negative values symmetrically, and is therefore free of sign bias. More importantly, for reasonable distributions of ''y'' values, the expected (average) value of the rounded numbers is the same as that of the original numbers. However, this rule will introduce a towards-zero bias when {{nowrap|y − 0.5}} is odd, and a towards-infinity bias for when it is even.
The integral over finite interval can then be evaluated by ordinary integration methods.


This variant is almost never used in computations, except in situations where one wants to avoid rounding 0.5 or −0.5 to zero; or to avoid increasing the scale of floating point numbers, which have a limited exponent range. With ''round half to even'', a non ''infinite'' number would round to infinity, and a small ''denormal'' value would round to a normal non-zero value.
==== Half-infinite intervals ====
Effectively, this mode prefers preserving the existing scale of tie numbers, avoiding out of range results when possible for even based number systems (such as binary and decimal).
An integral over a half-infinite interval can likewise be transformed into an integral over a finite interval by any one of several possible changes of variables, for example:


=== Stochastic rounding ===
:<math>
Another unbiased tie-breaking method is '''stochastic rounding''':
\int_a^{+\infty}f(x) \, dx =\int_0^1 f\left(a + \frac{1-t}{t}\right) \frac{dt}{t^2} .</math>


* If the fractional part of ''y'' is .5, choose ''q'' randomly among ''y'' + 0.5 and ''y'' − 0.5, with equal probability.
Similarly,


Like round-half-to-even, this rule is essentially free of overall bias; but it is also fair among even and odd ''q'' values.  On the other hand, it introduces a random component into the result; performing the same computation twice on the same data may yield two different results. Also, it is open to nonconscious bias if humans (rather than computers or devices of chance) are "randomly" deciding in which direction to round.
:<math>
\int_{-\infty}^a f(x) \, dx = \int_0^1 f\left(a - \frac{1-t}{t}\right) \frac{dt}{t^2}</math>


=== Alternating tie-breaking ===
== Multidimensional integrals ==
One method, more obscure than most, is '''round half alternatingly'''.


* If the fractional part is 0.5, alternate round up and round down: for the first occurrence of a 0.5 fractional part, round up; for the second occurrence, round down; so on so forth.
The quadrature rules discussed so far are all designed to compute one-dimensional integrals.
To compute integrals in multiple dimensions,
one approach is to phrase the multiple integral as repeated one-dimensional integrals by appealing to [[Fubini's theorem]].
This approach requires the function evaluations to [[exponential growth|grow exponentially]] as the number of dimensions increases. Two methods are known to overcome this so-called ''[[curse of dimensionality]]''.


This suppresses the random component of the result, if occurrences of 0.5 fractional parts can be effectively numbered. But it can still introduce a positive or negative bias according to the direction of rounding assigned to the first occurrence, if the total number of occurrences is odd.
=== Monte Carlo ===


==Dithering and error diffusion==
{{main|Monte Carlo integration}}
When digitising continuous signals, for example images or sound, the overall effect of a number of measurements is more important than the accuracy of each individual measurement. In these circumstances [[dithering]], and a related technique, [[error diffusion]], are normally used. A related technique called [[pulse-width modulation]] is used to achieve analogue type output from an inertial device by rapidly pulsing the power with a variable duty cycle.


Error diffusion tries to ensure the error on average is minimized. When dealing with a gentle slope from one to zero the output would be zero for the first few terms until the sum of the error and the current value becomes greater than 0.5, in which case a 1 is output and the difference subtracted from the error so far. [[Floyd–Steinberg dithering]] is a popular error diffusion procedure when digitising images.
[[Monte Carlo method]]s and [[quasi-Monte Carlo method]]s are easy to apply to multi-dimensional integrals,
and may yield greater accuracy for the same number of function evaluations than repeated integrations using one-dimensional methods.


==Rounding to simple fractions==
A large class of useful Monte Carlo methods are the so-called [[Markov chain Monte Carlo]] algorithms,
In some contexts it is desirable to round a given number ''x'' to a "neat" fraction — that is, the nearest fraction ''z''&nbsp;=&nbsp;''m''/''n'' whose numerator ''m'' and denominator ''n'' do not exceed a given maximum.  This problem is fairly distinct from that of rounding a value to a fixed number of decimal or binary digits, or to a multiple of a given unit ''m''.  This problem is related to [[Farey sequence]]s, the [[Stern–Brocot tree]], and [[continued fraction]]s.
which include the [[Metropolis-Hastings algorithm]] and [[Gibbs sampling]].


== Scaled rounding ==
=== Sparse grids ===
This type of rounding, which is also named '''rounding to a logarithmic scale''', is a variant of [[#Rounding to a specified increment|Rounding to a specified increment]]. Rounding on a logarithmic scale is accomplished by taking the log of the amount and doing normal rounding to the nearest value on the log scale.
[[Sparse grid]]s were originally developed by Smolyak for the quadrature of high dimensional functions. The method is always based on a one dimensional quadrature rule, but performs a more sophisticated combination of univariate results.


For example resistors are supplied with [[preferred number]]s on a logarithmic scale. For example for resistors with 10% accuracy they are supplied with nominal values 100,  121,  147,  178,  215 etc. If a calculation indicates a resistor of 165 ohms is required then log(147)=2.167, log(165)=2.217 and log(178)=2.250. The logarithm of 165 is closer to the logarithm of 178 therefore a 178 ohm resistor would be the first choice if there are no other considerations.
== Connection with differential equations ==


== Round to available value ==
The problem of evaluating the integral
:<math>\int_a^b f(x)\, dx</math>
can be reduced to an [[initial value problem]] for an [[ordinary differential equation]]. If the above integral is denoted by ''I''(''b''), then the function ''I'' satisfies
:<math> I'(x) = f(x), \quad I(a) = 0. </math>
Methods developed for ordinary differential equations, such as [[Runge–Kutta methods]], can be applied to the restated problem and thus be used to evaluate the integral. For instance, the standard fourth-order Runge–Kutta method applied to the differential equation yields Simpson's rule from above.


Finished [[lumber]], writing paper, capacitors, and many other products are usually sold in only a few standard sizes.
The differential equation ''I''&thinsp;'&thinsp;(''x'') = &fnof;(''x'') has a special form: the right-hand side contains only the dependent variable (here ''x'') and not the independent variable (here ''I''). This simplifies the theory and algorithms considerably. The problem of evaluating integrals is thus best studied in its own right.


Many design procedures describe how to calculate an approximate value, and then "round" to some standard size using phrases such as "round down to nearest standard value", "round up to nearest standard value", or "round to nearest standard value".<ref>
==See also==
[http://www.kennethkuhn.com/students/ee431/text/voltage_regulators_zeners.pdf "Zener Diode Voltage Regulators"]</ref><ref>
* [[Numerical ordinary differential equations]]
[http://stellafane.org/tm/atm/test/tester-3.html "Build a Mirror Tester"]</ref>
* [[Truncation error (numerical integration)]]
* [[Clenshaw–Curtis quadrature]]
* [[Gauss-Kronrod quadrature]]
* [[Riemann Sum]] or [[Riemann Integral]]
* [[Trapezoidal Rule]]


When a set of [[preferred value]]s is equally spaced on a logarithmic scale, choosing the closest [[preferred value]] to any given value can be seen as a kind of scaled rounding. Such "rounded" values can be directly calculated.<ref>
== References ==
Bruce Trump, Christine Schneider.
{{reflist}}
"Excel Formula Calculates Standard 1%-Resistor Values".
* [[Philip J. Davis]] and [[Philip Rabinowitz (mathematician)|Philip Rabinowitz]], ''Methods of Numerical Integration''.
Electronic Design, January 21, 2002.
* George E. Forsythe, Michael A. Malcolm, and Cleve B. Moler. ''Computer Methods for Mathematical Computations''. Englewood Cliffs, NJ: Prentice-Hall, 1977. ''(See Chapter  5.)''
[http://electronicdesign.com/article/components/excel-formula-calculates-standard-1-resistor-value.aspx]
* {{Citation |last1=Press|first1=WH|last2=Teukolsky|first2=SA|last3=Vetterling|first3=WT|last4=Flannery|first4=BP|year=2007|title=Numerical Recipes: The Art of Scientific Computing|edition=3rd|publisher=Cambridge University Press| publication-place=New York|isbn=978-0-521-88068-8|chapter=Chapter 4. Integration of Functions|chapter-url=http://apps.nrbook.com/empanel/index.html?pg=155}}
</ref>
* Josef Stoer and Roland Bulirsch. ''Introduction to Numerical Analysis''. New York: Springer-Verlag, 1980. ''(See Chapter 3.)''


==Floating-point rounding==
==External links==
In floating-point arithmetic, rounding aims to turn a given value ''x'' into a value ''z'' with a specified number of ''significant'' digits.  In other words, ''z'' should be a multiple of a number ''m'' that depends on the magnitude of ''x''.  The number ''m'' is a power of the base (usually 2 or 10) of the floating-point representation.
* [http://numericalmethods.eng.usf.edu/mws/gen/07int/index.html Integration: Background, Simulations, etc.] at Holistic Numerical Methods Institute
 
Apart from this detail, all the variants of rounding discussed above apply to the rounding of floating-point numbers as well. The algorithm for such rounding is presented in the [[#Scaled rounding|Scaled rounding]] section above, but with a constant scaling factor ''s''=1, and an integer base ''b''>1.
 
For results where the rounded result would overflow the result for a directed rounding is either the appropriate signed infinity, or the highest representable positive finite number (or the lowest representable negative finite number if ''x'' is negative), depending on the direction of rounding. The result of an overflow for the usual case of ''round to even'' is always the appropriate infinity.
 
In addition, if the rounded result would underflow, i.e. if the exponent would exceed the lowest representable integer value, the effective result may be either zero (possibly signed if the representation can maintain a distinction of [[Signed zero|signs for zeroes]]), or the smallest representable positive finite number (or the highest representable negative finite number if ''x'' is negative), possibly a ''denormal'' positive or negative number (if the mantissa is storing all its significant digits, in which case the most significant digit may still be stored in a lower position by setting the highest stored digits to zero, and this stored mantissa does not drop the most significant digit, something that is possible when base ''b''=2 because the most significant digit is always 1 in that base), depending on the direction of rounding. The result of an underflow for the usual case of ''round to even'' is always the appropriate zero.
 
== Double rounding ==
 
Rounding a number twice in succession to different precisions, with the latter precision being coarser, is not guaranteed to give the same result as rounding once to the final precision except in the case of directed rounding. For instance rounding 9.46 to one decimal gives 9.5, and then 10 when rounding to integer using rounding half to even, but would give 9 when rounded to integer directly.
 
In ''Martinez v. Allstate'' and ''Sendejo v. Farmers'', litigated between 1995 and 1997, the insurance companies argued that double rounding premiums was permissible and in fact required. The US courts ruled against the insurance companies and ordered them to adopt rules to ensure single rounding.<ref>{{cite book|title=Class Action Dilemmas: Pursuing Public Goals for Private Gain |author=Deborah R. Hensler |pages=255–293 | isbn=0-8330-2601-1 |publisher=RAND| year=2000}}</ref>
 
Some computer languages and the [[IEEE 754-2008]] standard dictate that in straightforward calculations the result should not be rounded twice. This has been a particular problem with Java as it is designed to be run identically on different machines, special programming tricks have had to be used to achieve this with [[x87]] floating point.<ref>{{cite journal
|title=When is double rounding innocuous? |author=Samuel A. Figueroa |publisher=ACM
|url=http://portal.acm.org/citation.cfm?id=221332.221334
|journal=ACM SIGNUM Newsletter |volume=30 |issue=3 |date=July 1995 |pages= 21–25 |doi=10.1145/221332.221334}}</ref><ref>{{cite web
|title=Efficiently producing default orthogonal IEEE double results using extended IEEE hardware
|author=Roger Golliver |publisher=Intel |date=October 1998
|url=http://www.open-std.org/JTC1/SC22/JSG/docs/m3/docs/jsgn326.pdf}}</ref>
The Java language was changed to allow different results where the difference does not matter and require a [[strictfp]] qualifier to be used when the results have to conform accurately.
 
== Exact computation with rounded arithmetic ==
It is possible to use rounded arithmetic to evaluate the exact value of a function with a discrete domain and range.  For example, if we know that an integer ''n'' is a perfect square, we can compute its square root by converting ''n'' to a floating-point value ''x'', computing the approximate square root ''y'' of ''x'' with floating point, and then rounding ''y'' to the nearest integer ''q''.  If ''n'' is not too big, the floating-point roundoff error in ''y'' will be less than 0.5, so the rounded value ''q'' will be the exact square root of ''n''.  In most modern computers, this method may be much faster than computing the square root of ''n'' by an all-integer algorithm.{{citation needed|date=November 2012}}
 
== The table-maker's dilemma ==
 
[[William Kahan]] coined the term "The Table-Maker's Dilemma" for the unknown cost of rounding [[transcendental function]]s:
<blockquote>"Nobody knows how much it would cost to compute y^w correctly rounded for ''every'' two floating-point arguments at which it does not over/underflow. Instead, reputable math libraries compute elementary [[transcendental function]]s mostly within slightly more than half an [[Unit in the last place|ulp]] and almost always well within one ulp. Why can't y^w be rounded within half an ulp like SQRT? Because nobody knows how much computation it would cost... No general way exists to predict how many extra digits will have to be carried to compute a transcendental expression and round it ''correctly'' to some preassigned number of digits. Even the fact (if true) that a finite number of extra digits will ultimately suffice may be a deep theorem."<ref>{{cite web |last=Kahan |first=William |title=A Logarithm Too Clever by Half |url=http://www.cs.berkeley.edu/~wkahan/LOG10HAF.TXT |accessdate=2008-11-14}}</ref></blockquote>
 
The [[IEEE floating point standard]] guarantees that add, subtract, multiply, divide, [[fused multiply–add]], square root, and floating point remainder will give the correctly rounded result of the infinite precision operation. No such guarantee was given in the 1985 standard for more complex functions and they are typically only accurate to within the last bit at best. However, the 2008 standard guarantees that conforming implementations will give correctly rounded results which respect the active rounding mode; implementation of the functions, however, is optional.
 
Using the [[Gelfond–Schneider theorem]] and [[Lindemann–Weierstrass theorem]] many of the standard elementary  functions can be proved to return [[transcendental number|transcendental]] results when given rational non-zero arguments; therefore it is always possible to correctly round such functions. However, determining a limit for a given precision on how accurate results need to be computed, before a correctly rounded result can be guaranteed, may demand a lot of computation time.<ref>''Handbook of Floating-Point Arithmetic'', J.-M. Muller et al., Chapter 12 ''Solving the Table Maker's Dilemma'', 2011.</ref>


Some packages offer correct rounding. The [[MPFR|GNU MPFR]] package gives correctly rounded arbitrary precision results. Some other libraries implement elementary functions with correct rounding in double precision:
=== Free software for numerical integration ===
* [[IBM]]'s libultim, in rounding to nearest only.<ref>{{cite web|url=http://www.math.utah.edu/cgi-bin/man2html.cgi?/usr/local/man/man3/libultim.3|title=libultim - ultimate correctly-rounded elementary-function library}}</ref>
* [[Sun Microsystems]]'s libmcr, in the 4 rounding modes.<ref>{{cite web|url=http://www.math.utah.edu/cgi-bin/man2html.cgi?/usr/local/man/man3/libmcr.3|title=libmcr - correctly-rounded elementary-function library}}</ref>
* CRlibm, written in the Arénaire team (LIP, [[ENS Lyon]]). It supports the 4 rounding modes and is proved.<ref>{{cite web|url=http://lipforge.ens-lyon.fr/www/crlibm/|title=CRlibm - Correctly Rounded mathematical library}}</ref>


There exist [[computable number]]s which a rounded value can never be determined no matter how many digits are calculated. Specific instances cannot be given but this follows from the undecidability of the [[halting problem]]. For instance, if [[Goldbach's conjecture]] is true but [[unprovable]], then the result of rounding the following value up to the next integer cannot be determined: 10<sup>−n</sup> where n is the first even number greater than 4 which is not the sum of two primes, or 0 if there is no such number. The result is 1 if such a number exists and 0 if no such number exists. The value before rounding can however be approximated to any given precision even if the conjecture is unprovable.
Numerical integration is one of the most intensively studied problems in numerical analysis.
Of the many software implementations, we list a few [[free and open source software]] packages here:


==History==
* [[QUADPACK]] (part of SLATEC): description [http://www.netlib.org/slatec/src/qpdoc.f], source code [http://www.netlib.org/slatec/src]. QUADPACK is a collection of algorithms, in Fortran, for numerical integration based on Gaussian quadrature.
The concept of rounding is very old, perhaps older even than the concept of division. Some ancient [[clay tablet]]s found in [[Mesopotamia]] contain tables with rounded values of [[Multiplicative inverse|reciprocals]] and square roots in base 60.<ref>
* [http://openopt.org/interalg interalg]: a solver from [[OpenOpt]]/[[FuncDesigner]] frameworks, based on interval analysis, '''guaranteed precision''', license: BSD (free for any purposes)
[http://it.stlawu.edu/%7Edmelvill/mesomath/tablets/YBC7289.html Duncan J. Melville. "YBC 7289 clay tablet". 2006]</ref>
* [http://www.gnu.org/software/gsl/ GSL]: The GNU Scientific Library (GSL) is a numerical library written in C which provides a wide range of mathematical routines, like Monte Carlo integration.
Rounded approximations to [[pi|π]], the length of the year, and the length of the month are also ancient—see [[base 60#Examples]].
* Numerical integration algorithms are found in [[Guide to Available Mathematical Software|GAMS]] class [http://gams.nist.gov/serve.cgi/Class/H2 H2].
* [http://www.alglib.net/integral/ ALGLIB] is a collection of algorithms, in C# / C++ / Delphi / Visual Basic / etc., for numerical integration (includes Bulirsch-Stoer and Runge-Kutta integrators).
* [http://www.feynarts.de/cuba/ Cuba] is a free-software library of several multi-dimensional integration algorithms.
* [http://ab-initio.mit.edu/wiki/index.php/Cubature Cubature] code for adaptive multi-dimensional integration.
* [http://www.scilab.org/ Scilab] is an open source software under GPL license, providing powerful features including numerical integration.


The ''Round-to-even'' method has served as the [[ASTM]] (E-29) standard since 1940.  The origin of the terms ''unbiased rounding'' and ''statistician's rounding'' are fairly self-explanatory.  In the 1906 4th edition of ''Probability and Theory of Errors'' <ref>http://historical.library.cornell.edu/cgi-bin/cul.math/docviewer?did=05170001&view=50&frames=0&seq=48</ref> [[Robert Simpson Woodward]] called this "the computer's rule" indicating that it was then in common use by [[human computer]]s who calculated mathematical tables. [[Churchill Eisenhart]] indicated the practice was already "well established" in data analysis by the 1940s.<ref>{{cite book|title=Selected Techniques of Statistical Analysis for Scientific and Industrial Research, and Production and Management Engineering|publisher=McGraw-Hill|location=New York|pages=187–223|url=https://archive.org/details/selectedtechniqu00colu|author=Churchill Eisenhart|editor=Eisenhart, Hastay, and Wallis|accessdate=30 January 2014|archivedate=2 April 2012|chapter=Effects of Rounding or Grouping Data|year=1947}}</ref>
[[Category:Numerical analysis]]
 
[[Category:Numerical integration (quadrature)|*]]
The origin of the term ''bankers' rounding'' remains more obscure.  If this rounding method was ever a standard in banking, the evidence has proved extremely difficult to find.  To the contrary, section 2 of the European Commission report ''The Introduction of the Euro and the Rounding of Currency Amounts'' <ref>http://ec.europa.eu/economy_finance/publications/publication1224_en.pdf</ref> suggests that there had previously been no standard approach to rounding in banking; and it specifies that "half-way" amounts should be rounded up.
[[Category:Articles with example Python code]]
 
Until the 1980s, the rounding method used in floating-point computer arithmetic was usually fixed by the hardware, poorly documented, inconsistent, and different for each brand and model of computer.  This situation changed after the IEEE 754 floating point standard was adopted by most computer manufacturers. The standard allows the user to choose among several rounding modes, and in each case specifies precisely how the results should be rounded. These features made numerical computations more predictable and machine-independent, and made possible the efficient and consistent implementation of [[interval arithmetic]].
 
==Rounding functions in programming languages==
Most [[programming language]]s provide functions or special syntax to round fractional numbers in various ways.  The earliest numeric languages, such as [[FORTRAN]] and [[C (programming language)|C]], would provide only one method, usually truncation (towards zero).  This default method could be implied in certain contexts, such as when assigning a fractional number to an [[integer (computing)|integer]] [[variable (programming)|variable]], or using a fractional number as an index of an [[array data type|array]].  Other kinds of rounding had to be programmed explicitly; for example, rounding a positive number to the nearest integer could be implemented by adding 0.5 and truncating.
 
In the last decades, however, the syntax and/or the standard [[library (computing)|libraries]] of most languages have commonly provided at least the four basic rounding functions (up, down, to nearest, and towards zero).  The tie-breaking method may vary depending the language and version, and/or may be selectable by the programmer.  Several languages follow the lead of the IEEE-754 floating-point standard, and define these functions as taking a [[Double precision floating-point format|double precision float]] argument and returning the result of the same type, which then may be converted to an integer if necessary.  Since the IEEE double precision format has 52 fraction bits, this approach may avoid spurious [[arithmetic overflow|overflows]] in languages having 32-bit integers.  Some languages, such as [[PHP]], provide functions that round a value to a specified number of decimal digits, e.g. from 4321.5678 to 4321.57 or 4300.  In addition, many languages provide a [[printf]] or similar string formatting function, which allows one to convert a fractional number to a string, rounded to a user-specified number of decimal places (the ''precision'').  On the other hand, truncation (round to zero) is still the default rounding method used by many languages, especially for the division of two integer values.
 
On the opposite, [[Cascading Style Sheets|CSS]] and [[Scalable Vector Graphics|SVG]] do not define any specific maximum precision for numbers and measurements, that are treated and exposed in their [[Document Object Model|DOM]] and in their [[Interface description language|IDL]] interface as strings as if they had infinite precision, and do not discriminate between integers and floating point values; however, the implementations of these languages will typically convert these numbers into IEEE-754 double floating points before exposing the computed digits with a limited precision (notably within standard [[JavaScript]] or [[ECMAScript]]<ref>[http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf ECMA-262 ECMAScript Language Specification]</ref> interface bindings).
 
== Other rounding standards ==
 
Some disciplines or institutions have issued standards or directives for rounding.
 
=== U.S. Weather Observations ===
 
In a guideline issued in mid-1966,<ref>OFCM, 2005: [http://www.ofcm.gov/fmh-1/fmh1.htm Federal Meteorological Handbook No. 1], Washington, DC., 104 pp.</ref> the [[United States|U.S.]] [[Office of the Federal Coordinator for Meteorology]] determined that weather data should be rounded to the nearest  round number, with the "round half up" tie-breaking rule.  For example, 1.5 rounded to integer should become 2, and −1.5 should become −1.  Prior to that date, the tie-breaking rule was "round half away from zero".
 
=== Negative zero in meteorology ===
Some [[meteorology|meteorologist]]s may write "&minus;0" to indicate a temperature between 0.0 and &minus;0.5 degrees (exclusive) that was rounded to integer.  This notation is used when the negative sign is considered important, no matter how small is the magnitude; for example, when rounding temperatures in the [[Celsius]] scale, where below zero indicates freezing.{{Citation needed|date=July 2009}}
 
==See also==
* [[Gal's accurate tables]]
* [[Interval arithmetic]]
* [[ISO 80000-1|ISO 80000-1:2009]]
* [[Kahan summation algorithm]]
* [[Nearest integer function]]
* [[Truncation]]
* [[Signed-digit representation]]
* [[Swedish rounding]], to avoid the use of coins of extremely low value
 
== References ==
{{Reflist|2}}
 
==External links==
* [http://www.clivemaxfield.com/diycalculator/popup-m-round.shtml An introduction to different rounding algorithms] that is accessible to a general audience but especially useful to those studying computer science and electronics.
* [http://support.microsoft.com/kb/196652 How To Implement Custom Rounding Procedures] by Microsoft


[[Category:Arithmetic]]
[[ar:تكامل عددي]]
[[Category:Computer arithmetic]]
[[ca:Integració numèrica]]
[[Category:Theory of computation]]
[[de:Numerische Integration]]
[[es:Integración numérica]]
[[fr:Calcul numérique d'une intégrale]]
[[ko:수치적분]]
[[it:Integrazione numerica]]
[[kk:Сандық интегралдау]]
[[he:שיטות נומריות לחישוב אינטגרלים מסוימים]]
[[hu:Numerikus integrálás]]
[[nl:Numerieke integratie]]
[[ja:数値積分]]
[[pl:Całkowanie numeryczne]]
[[pt:Integração numérica]]
[[ru:Численное интегрирование]]
[[sr:Нумеричка интеграција]]
[[sv:Numerisk integrering]]
[[uk:Чисельне інтегрування]]
[[zh:數值積分]]

Revision as of 09:25, 10 August 2014

Numerical integration consists of finding numerical approximations for the value

In numerical analysis, numerical integration constitutes a broad family of algorithms for calculating the numerical value of a definite integral, and by extension, the term is also sometimes used to describe the numerical solution of differential equations. This article focuses on calculation of definite integrals. The term numerical quadrature (often abbreviated to quadrature) is more or less a synonym for numerical integration, especially as applied to one-dimensional integrals. Numerical integration over more than one dimension is sometimes described as cubature,[1] although the meaning of quadrature is understood for higher dimensional integration as well.

The basic problem considered by numerical integration is to compute an approximate solution to a definite integral:

If Buying, selling and renting HDB and personal residential properties in Singapore are simple and transparent transactions. Although you are not required to engage a real property salesperson (generally often known as a "public listed property developers In singapore agent") to complete these property transactions, chances are you'll think about partaking one if you are not accustomed to the processes concerned.

Professional agents are readily available once you need to discover an condominium for hire in singapore In some cases, landlords will take into account you more favourably in case your agent comes to them than for those who tried to method them by yourself. You need to be careful, nevertheless, as you resolve in your agent. Ensure that the agent you are contemplating working with is registered with the IEA – Institute of Estate Brokers. Whereas it might sound a hassle to you, will probably be worth it in the end. The IEA works by an ordinary algorithm and regulations, so you'll protect yourself in opposition to probably going with a rogue agent who prices you more than they should for his or her service in finding you an residence for lease in singapore.

There isn't any deal too small. Property agents who are keen to find time for any deal even if the commission is small are the ones you want on your aspect. Additionally they present humbleness and might relate with the typical Singaporean higher. Relentlessly pursuing any deal, calling prospects even without being prompted. Even if they get rejected a hundred times, they still come again for more. These are the property brokers who will find consumers what they need eventually, and who would be the most successful in what they do. 4. Honesty and Integrity

This feature is suitable for you who need to get the tax deductions out of your PIC scheme to your property agency firm. It's endorsed that you visit the correct site for filling this tax return software. This utility must be submitted at the very least yearly to report your whole tax and tax return that you're going to receive in the current accounting 12 months. There may be an official website for this tax filling procedure. Filling this tax return software shouldn't be a tough thing to do for all business homeowners in Singapore.

A wholly owned subsidiary of SLP Worldwide, SLP Realty houses 900 associates to service SLP's fast rising portfolio of residential tasks. Real estate is a human-centric trade. Apart from offering comprehensive coaching applications for our associates, SLP Realty puts equal emphasis on creating human capabilities and creating sturdy teamwork throughout all ranges of our organisational hierarchy. Worldwide Presence At SLP International, our staff of execs is pushed to make sure our shoppers meet their enterprise and investment targets. Under is an inventory of some notable shoppers from completely different industries and markets, who've entrusted their real estate must the expertise of SLP Worldwide.

If you're looking for a real estate or Singapore property agent online, you merely need to belief your instinct. It is because you don't know which agent is sweet and which agent will not be. Carry out research on a number of brokers by looking out the internet. As soon as if you find yourself certain that a selected agent is dependable and trustworthy, you'll be able to choose to utilize his partnerise find you a house in Singapore. More often than not, a property agent is considered to be good if she or he places the contact data on his web site. This is able to imply that the agent does not thoughts you calling them and asking them any questions regarding properties in Singapore. After chatting with them you too can see them of their office after taking an appointment.

Another method by way of which you could find out whether the agent is sweet is by checking the feedback, of the shoppers, on the website. There are various individuals would publish their comments on the web site of the Singapore property agent. You can take a look at these feedback and the see whether it will be clever to hire that specific Singapore property agent. You may even get in contact with the developer immediately. Many Singapore property brokers know the developers and you may confirm the goodwill of the agent by asking the developer. is a smooth well-behaved function, integrated over a small number of dimensions and the limits of integration are bounded, there are many methods of approximating the integral with arbitrary precision.

Reasons for numerical integration

There are several reasons for carrying out numerical integration. The integrand f(x) may be known only at certain points, such as obtained by sampling. Some embedded systems and other computer applications may need numerical integration for this reason.

A formula for the integrand may be known, but it may be difficult or impossible to find an antiderivative which is an elementary function. An example of such an integrand is f(x) = exp(−x2), the antiderivative of which (the error function, times a constant) cannot be written in elementary form.

It may be possible to find an antiderivative symbolically, but it may be easier to compute a numerical approximation than to compute the antiderivative. That may be the case if the antiderivative is given as an infinite series or product, or if its evaluation requires a special function which is not available.

Methods for one-dimensional integrals

Numerical integration methods can generally be described as combining evaluations of the integrand to get an approximation to the integral. The integrand is evaluated at a finite set of points called integration points and a weighted sum of these values is used to approximate the integral. The integration points and weights depend on the specific method used and the accuracy required from the approximation.

An important part of the analysis of any numerical integration method is to study the behavior of the approximation error as a function of the number of integrand evaluations. A method which yields a small error for a small number of evaluations is usually considered superior. Reducing the number of evaluations of the integrand reduces the number of arithmetic operations involved, and therefore reduces the total round-off error. Also, each evaluation takes time, and the integrand may be arbitrarily complicated.

A 'brute force' kind of numerical integration can be done, if the integrand is reasonably well-behaved (i.e. piecewise continuous and of bounded variation), by evaluating the integrand with very small increments.

Quadrature rules based on interpolating functions

A large class of quadrature rules can be derived by constructing interpolating functions which are easy to integrate. Typically these interpolating functions are polynomials.

Illustration of the rectangle rule.

The simplest method of this type is to let the interpolating function be a constant function (a polynomial of degree zero) which passes through the point ((a+b)/2, f((a+b)/2)). This is called the midpoint rule or rectangle rule.

Illustration of the trapezoidal rule.

The interpolating function may be an affine function (a polynomial of degree 1) which passes through the points (a, f(a)) and (b, f(b)). This is called the trapezoidal rule.

Illustration of Simpson's rule.

For either one of these rules, we can make a more accurate approximation by breaking up the interval [a, b] into some number n of subintervals, computing an approximation for each subinterval, then adding up all the results. This is called a composite rule, extended rule, or iterated rule. For example, the composite trapezoidal rule can be stated as

where the subintervals have the form [k h, (k+1) h], with h = (ba)/n and k = 0, 1, 2, ..., n−1.

Interpolation with polynomials evaluated at equally spaced points in [a, b] yields the Newton–Cotes formulas, of which the rectangle rule and the trapezoidal rule are examples. Simpson's rule, which is based on a polynomial of order 2, is also a Newton–Cotes formula.

Quadrature rules with equally spaced points have the very convenient property of nesting. The corresponding rule with each interval subdivided includes all the current points, so those integrand values can be re-used.

If we allow the intervals between interpolation points to vary, we find another group of quadrature formulas, such as the Gaussian quadrature formulas. A Gaussian quadrature rule is typically more accurate than a Newton–Cotes rule which requires the same number of function evaluations, if the integrand is smooth (i.e., if it is sufficiently differentiable). Other quadrature methods with varying intervals include Clenshaw–Curtis quadrature (also called Fejér quadrature) methods, which do nest.

Gaussian quadrature rules do not nest, but the related Gauss–Kronrod quadrature formulas do.

Adaptive algorithms

DTZ gives a comprehensive integrated property and services administration resolution for buyers, corporate house for sale In singapore owners, management firms and occupiers of property whatever their needs with the only goal of optimising and enhancing the investment worth of their property. We at the moment make use of a staff of more than 70 skilled staffs who are well-trained and dedicated to collectively achieving our purchasers' objectives.

Actual estate agency specialising in non-public condos and landed properties island vast. 10 Winstedt Highway, District 10, #01-thirteen, Singapore 227977. Property providers for enterprise relocation. Situated at 371 Beach Street, #19-10 KeyPoint, Singapore 199597. Property agents for homes, town houses, landed property, residences and condominium for sales and rentals of properties. Administration letting services for property homeowners. is there a single authority in singapore who regulates real property agents that i can file a complaint with for unethical behaviour? or is CASE is simply route? The 188 pages of Secrets and techniques of Singapore Property Gurus are full of professional knowledge and life altering wisdom. Asian industrial property market outlook Property Listing Supervisor Property Advertising Services

Should sellers go along with an agent who claims to specialize in your space? His experience might turn out to be useful, but he is probably additionally advertising a number of models within the neighbourhood – and so they're all your rivals. Within the worst-case state of affairs, your house may be used as a "showflat" as house owner YS Liang found. "Weekend after weekend, our agent would convey a stream of individuals to speed-go to our apartment, leaving within minutes. She did not even try to promote our condominium. It felt like we were just one of the many tour stops for her clients," he complains.

Step one in direction of conducting enterprise as an actual property company in Singapore is to include an organization, or if you happen to're going the partnership or sole-proprietorship route, register your Limited Legal responsibility Partnership or sole-proprietorship with the ACRA (Accounting and Company Regulatory Authority of Singapore) Whether or not you might be considering to promote, let, hire or buy a new industrial property, we're right here to assist. Search and browse our commercial property section. Possess not less than 3 years of working expertise below a Singapore licensed real-property agency; Sale, letting and property administration and taxation companies. three Shenton Means, #10-08 Shenton Home, Singapore 068805. Real property agents for purchasing, promoting, leasing, and renting property. Caveat Search

Firstly, the events might take into account to rescind the sale and buy agreement altogether. This avenue places the contracting events to a position as if the contract didn't happen. It's as if the contract was terminated from the start and events are put back into place that they were before the contract. Any items or monies handed are returned to the respective original house owners. As the worldwide real property market turns into extra refined and worldwide real property investments will increase, the ERA real estate network is well equipped to offer professional recommendation and guidance to our shoppers in making critical actual estate decisions. Relocationg, leasing and sales of properties for housing, food and beverage, retail and workplace wants.

Pasir Panjang, Singapore - $5,000-6,000 per 30 days By likelihood one among our buddies here in Singapore is an agent and we made contact for her to help us locate an residence, which she did. days from the date of execution if the doc is signed in Singapore; Be a Singapore Citizen or PR (Permanent Resident); The regulations also prohibit property agents from referring their shoppers to moneylenders, to discourage irresponsible shopping for. Brokers are additionally prohibited from holding or dealing with money on behalf of any party in relation to the sale or purchase of any property situated in Singapore, and the lease of HDB property. - Negotiate To Close A Sale together with sale and lease of HDB and private properties) Preparing your house for sale FEATURED COMMERCIAL AGENTS Property Guides

i) registered as a patent agent or its equal in any nation or territory, or by a patent workplace, specified within the Fourth Schedule; The business-specific tips for the true property agency and telecommunication sectors have been crafted to address considerations about scenarios that particularly apply to the two sectors, the PDPC stated. Mr Steven Tan, Managing Director of OrangeTee real property company, nonetheless, felt that it was a matter of "practising until it becomes part of our knowledge". "After a while, the agents ought to know the spirit behind the (Act)," he stated. Rising office sector leads real property market efficiency, while prime retail and enterprise park segments moderate and residential sector continues in decline Please choose an attendee for donation.

If f(x) does not have many derivatives at all points, or if the derivatives become large, then Gaussian quadrature is often insufficient. In this case, an algorithm similar to the following will perform better:


def calculate_definite_integral_of_f(f, initial_step_size):
    '''
    This algorithm calculates the definite integral of a function
    from 0 to 1, adaptively, by choosing smaller steps near
    problematic points.
    '''
    x = 0.0
    h = initial_step_size
    accumulator = 0.0
    while x < 1.0:
        if x + h > 1.0:
            h = 1.0 - x
        quad_this_step =
        if error_too_big_in_quadrature_of_over_range(f, [x,x+h]):
            h = make_h_smaller(h)
        else:
            accumulator += quadrature_of_f_over_range(f, [x,x+h])
            x += h
            if error_too_small_in_quadrature_of_over_range(f, [x,x+h]):
                h = make_h_larger(h) # Avoid wasting time on tiny steps.
    return accumulator

Some details of the algorithm require careful thought. For many cases, estimating the error from quadrature over an interval for a function f(x) isn't obvious. One popular solution is to use two different rules of quadrature, and use their difference as an estimate of the error from quadrature. The other problem is deciding what "too large" or "very small" signify. A local criterion for "too large" is that the quadrature error should not be larger than t · h where t, a real number, is the tolerance we wish to set for global error. Then again, if h is already tiny, it may not be worthwhile to make it even smaller even if the quadrature error is apparently large. A global criterion is that the sum of errors on all the intervals should be less than t. This type of error analysis is usually called "a posteriori" since we compute the error after having computed the approximation.

Heuristics for adaptive quadrature are discussed by Forsythe et al. (Section 5.4).

Extrapolation methods

The accuracy of a quadrature rule of the Newton-Cotes type is generally a function of the number of evaluation points. The result is usually more accurate as number of evaluation points increases, or, equivalently, as the width of the step size between the points decreases. It is natural to ask what the result would be if the step size were allowed to approach zero. This can be answered by extrapolating the result from two or more nonzero step sizes, using series acceleration methods such as Richardson extrapolation. The extrapolation function may be a polynomial or rational function. Extrapolation methods are described in more detail by Stoer and Bulirsch (Section 3.4) and are implemented in many of the routines in the QUADPACK library.

Conservative (a priori) error estimation

Let f have a bounded first derivative over [a,b]. The mean value theorem for f, where x < b, gives

for some yx in [a,x] depending on x. If we integrate in x from a to b on both sides and take the absolute values, we obtain

We can further approximate the integral on the right-hand side by bringing the absolute value into the integrand, and replacing the term in f' by an upper bound:

(**)

(See supremum.) Hence, if we approximate the integral ∫ab f(x) dx by the quadrature rule (b − a)f(a) our error is no greater than the right hand side of (**). We can convert this into an error analysis for the Riemann sum (*), giving an upper bound of

for the error term of that particular approximation. (Note that this is precisely the error we calculated for the example .) Using more derivatives, and by tweaking the quadrature, we can do a similar error analysis using a Taylor series (using a partial sum with remainder term) for f. This error analysis gives a strict upper bound on the error, if the derivatives of f are available.

This integration method can be combined with interval arithmetic to produce computer proofs and verified calculations.

Integrals over infinite intervals

Infinite intervals

One way to calculate an integral over infinite interval,

is to transform it into an integral over a finite interval by any one of several possible changes of variables, for example:

The integral over finite interval can then be evaluated by ordinary integration methods.

Half-infinite intervals

An integral over a half-infinite interval can likewise be transformed into an integral over a finite interval by any one of several possible changes of variables, for example:

Similarly,

Multidimensional integrals

The quadrature rules discussed so far are all designed to compute one-dimensional integrals. To compute integrals in multiple dimensions, one approach is to phrase the multiple integral as repeated one-dimensional integrals by appealing to Fubini's theorem. This approach requires the function evaluations to grow exponentially as the number of dimensions increases. Two methods are known to overcome this so-called curse of dimensionality.

Monte Carlo

Mining Engineer (Excluding Oil ) Truman from Alma, loves to spend time knotting, largest property developers in singapore developers in singapore and stamp collecting. Recently had a family visit to Urnes Stave Church.

Monte Carlo methods and quasi-Monte Carlo methods are easy to apply to multi-dimensional integrals, and may yield greater accuracy for the same number of function evaluations than repeated integrations using one-dimensional methods.

A large class of useful Monte Carlo methods are the so-called Markov chain Monte Carlo algorithms, which include the Metropolis-Hastings algorithm and Gibbs sampling.

Sparse grids

Sparse grids were originally developed by Smolyak for the quadrature of high dimensional functions. The method is always based on a one dimensional quadrature rule, but performs a more sophisticated combination of univariate results.

Connection with differential equations

The problem of evaluating the integral

can be reduced to an initial value problem for an ordinary differential equation. If the above integral is denoted by I(b), then the function I satisfies

Methods developed for ordinary differential equations, such as Runge–Kutta methods, can be applied to the restated problem and thus be used to evaluate the integral. For instance, the standard fourth-order Runge–Kutta method applied to the differential equation yields Simpson's rule from above.

The differential equation I ' (x) = ƒ(x) has a special form: the right-hand side contains only the dependent variable (here x) and not the independent variable (here I). This simplifies the theory and algorithms considerably. The problem of evaluating integrals is thus best studied in its own right.

See also

References

43 year old Petroleum Engineer Harry from Deep River, usually spends time with hobbies and interests like renting movies, property developers in singapore new condominium and vehicle racing. Constantly enjoys going to destinations like Camino Real de Tierra Adentro.

  • Philip J. Davis and Philip Rabinowitz, Methods of Numerical Integration.
  • George E. Forsythe, Michael A. Malcolm, and Cleve B. Moler. Computer Methods for Mathematical Computations. Englewood Cliffs, NJ: Prentice-Hall, 1977. (See Chapter 5.)
  • Many property agents need to declare for the PIC grant in Singapore. However, not all of them know find out how to do the correct process for getting this PIC scheme from the IRAS. There are a number of steps that you need to do before your software can be approved.

    Naturally, you will have to pay a safety deposit and that is usually one month rent for annually of the settlement. That is the place your good religion deposit will likely be taken into account and will kind part or all of your security deposit. Anticipate to have a proportionate amount deducted out of your deposit if something is discovered to be damaged if you move out. It's best to you'll want to test the inventory drawn up by the owner, which can detail all objects in the property and their condition. If you happen to fail to notice any harm not already mentioned within the inventory before transferring in, you danger having to pay for it yourself.

    In case you are in search of an actual estate or Singapore property agent on-line, you simply should belief your intuition. It's because you do not know which agent is nice and which agent will not be. Carry out research on several brokers by looking out the internet. As soon as if you end up positive that a selected agent is dependable and reliable, you can choose to utilize his partnerise in finding you a home in Singapore. Most of the time, a property agent is taken into account to be good if he or she locations the contact data on his website. This may mean that the agent does not mind you calling them and asking them any questions relating to new properties in singapore in Singapore. After chatting with them you too can see them in their office after taking an appointment.

    Have handed an trade examination i.e Widespread Examination for House Brokers (CEHA) or Actual Property Agency (REA) examination, or equal; Exclusive brokers are extra keen to share listing information thus making certain the widest doable coverage inside the real estate community via Multiple Listings and Networking. Accepting a severe provide is simpler since your agent is totally conscious of all advertising activity related with your property. This reduces your having to check with a number of agents for some other offers. Price control is easily achieved. Paint work in good restore-discuss with your Property Marketing consultant if main works are still to be done. Softening in residential property prices proceed, led by 2.8 per cent decline within the index for Remainder of Central Region

    Once you place down the one per cent choice price to carry down a non-public property, it's important to accept its situation as it is whenever you move in – faulty air-con, choked rest room and all. Get round this by asking your agent to incorporate a ultimate inspection clause within the possibility-to-buy letter. HDB flat patrons routinely take pleasure in this security net. "There's a ultimate inspection of the property two days before the completion of all HDB transactions. If the air-con is defective, you can request the seller to repair it," says Kelvin.

    15.6.1 As the agent is an intermediary, generally, as soon as the principal and third party are introduced right into a contractual relationship, the agent drops out of the image, subject to any problems with remuneration or indemnification that he could have against the principal, and extra exceptionally, against the third occasion. Generally, agents are entitled to be indemnified for all liabilities reasonably incurred within the execution of the brokers´ authority.

    To achieve the very best outcomes, you must be always updated on market situations, including past transaction information and reliable projections. You could review and examine comparable homes that are currently available in the market, especially these which have been sold or not bought up to now six months. You'll be able to see a pattern of such report by clicking here It's essential to defend yourself in opposition to unscrupulous patrons. They are often very skilled in using highly unethical and manipulative techniques to try and lure you into a lure. That you must also protect your self, your loved ones, and personal belongings as you'll be serving many strangers in your home. Sign a listing itemizing of all of the objects provided by the proprietor, together with their situation. HSR Prime Recruiter 2010
  • Josef Stoer and Roland Bulirsch. Introduction to Numerical Analysis. New York: Springer-Verlag, 1980. (See Chapter 3.)

External links

Free software for numerical integration

Numerical integration is one of the most intensively studied problems in numerical analysis. Of the many software implementations, we list a few free and open source software packages here:

  • QUADPACK (part of SLATEC): description [1], source code [2]. QUADPACK is a collection of algorithms, in Fortran, for numerical integration based on Gaussian quadrature.
  • interalg: a solver from OpenOpt/FuncDesigner frameworks, based on interval analysis, guaranteed precision, license: BSD (free for any purposes)
  • GSL: The GNU Scientific Library (GSL) is a numerical library written in C which provides a wide range of mathematical routines, like Monte Carlo integration.
  • Numerical integration algorithms are found in GAMS class H2.
  • ALGLIB is a collection of algorithms, in C# / C++ / Delphi / Visual Basic / etc., for numerical integration (includes Bulirsch-Stoer and Runge-Kutta integrators).
  • Cuba is a free-software library of several multi-dimensional integration algorithms.
  • Cubature code for adaptive multi-dimensional integration.
  • Scilab is an open source software under GPL license, providing powerful features including numerical integration.

ar:تكامل عددي ca:Integració numèrica de:Numerische Integration es:Integración numérica fr:Calcul numérique d'une intégrale ko:수치적분 it:Integrazione numerica kk:Сандық интегралдау he:שיטות נומריות לחישוב אינטגרלים מסוימים hu:Numerikus integrálás nl:Numerieke integratie ja:数値積分 pl:Całkowanie numeryczne pt:Integração numérica ru:Численное интегрирование sr:Нумеричка интеграција sv:Numerisk integrering uk:Чисельне інтегрування zh:數值積分



  1. I had like 17 domains hosted on single account, and never had any special troubles. If you are not happy with the service you will get your money back with in 45 days, that's guaranteed. But the Search Engine utility inside the Hostgator account furnished an instant score for my launched website. Fantastico is unable to install WordPress in a directory which already have any file i.e to install WordPress using Fantastico the destination directory must be empty and it should not have any previous installation files. When you share great information, others will take note. Once your hosting is purchased, you will need to setup your domain name to point to your hosting. Money Back: All accounts of Hostgator come with a 45 day money back guarantee. If you have any queries relating to where by and how to use Hostgator Discount Coupon, you can make contact with us at our site. If you are starting up a website or don't have too much website traffic coming your way, a shared plan is more than enough. Condition you want to take advantage of the worldwide web you prerequisite a HostGator web page, -1 of the most trusted and unfailing web suppliers on the world wide web today. Since, single server is shared by 700 to 800 websites, you cannot expect much speed.



    Hostgator tutorials on how to install Wordpress need not be complicated, especially when you will be dealing with a web hosting service that is friendly for novice webmasters and a blogging platform that is as intuitive as riding a bike. After that you can get Hostgator to host your domain and use the wordpress to do the blogging. Once you start site flipping, trust me you will not be able to stop. I cut my webmaster teeth on Control Panel many years ago, but since had left for other hosting companies with more commercial (cough, cough) interfaces. If you don't like it, you can chalk it up to experience and go on. First, find a good starter template design. When I signed up, I did a search for current "HostGator codes" on the web, which enabled me to receive a one-word entry for a discount. Your posts, comments, and pictures will all be imported into your new WordPress blog.