Interval package: Difference between revisions

493 bytes added ,  15 October 2014
added hyperlinks and minor corrections
(Added references to other interval libraries)
(added hyperlinks and minor corrections)
Line 1: Line 1:
The [https://sourceforge.net/p/octave/interval/ interval package] provides data types and fundamental operations for real valued interval arithmetic based on the common floating-point format “binary64” a. k. a. double-precision.  '''Interval arithmetic''' produces mathematically proven numerical results.  It aims to be standard compliant with the (upcoming) [http://standards.ieee.org/develop/project/1788.html IEEE 1788] and therefore implements the ''set-based'' interval arithmetic flavor.
The [https://sourceforge.net/p/octave/interval/ interval package] provides data types and fundamental operations for real valued interval arithmetic based on the common floating-point format “binary64” a. k. a. double-precision.  It aims to be standard compliant with the (upcoming) [http://standards.ieee.org/develop/project/1788.html IEEE 1788] and therefore implements the ''set-based'' interval arithmetic flavor.  '''Interval arithmetic''' produces mathematically proven numerical results.


Warning: The package has not yet been released.
Warning: The package has not yet been released.
Line 20: Line 20:
|}
|}


Floating point arithmetic, as specified by [http://en.wikipedia.org/wiki/IEEE_floating_point IEEE 754], is available in almost every computer system today. It is wide-spread, implemented in common hardware and integral part in programming languages. For example, the extended precision format is the default numeric data type in GNU Octave. Benefits are obvious: The performance of arithmetic operations is well-defined, highly efficient and results are comparable between different systems.
Floating point arithmetic, as specified by [http://en.wikipedia.org/wiki/IEEE_floating_point IEEE 754], is available in almost every computer system today. It is wide-spread, implemented in common hardware and integral part in programming languages. For example, the extended precision format is the default numeric data type in GNU Octave. Benefits are obvious: The results of arithmetic operations are well-defined and comparable between different systems and computation is highly efficient.


However, there are some downsides of floating point arithmetic in practice, which will eventually produce errors in computations.
However, there are some downsides of floating point arithmetic in practice, which will eventually produce errors in computations.
* Floating point arithmetic is often used mindlessly by developers. [http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html]
* Floating point arithmetic is often used mindlessly by developers. [http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html]
* The binary data types categorically are not suitable for doing financial computations. Very often representational errors are introduced when using “real world” decimal numbers.
* The binary data types categorically are not suitable for doing financial computations. Very often representational errors are introduced when using “real world” decimal numbers. [http://en.wikipedia.org/wiki/Decimal_computer]
* Even if the developer would be proficient, most developing environments / technologies limit floating point arithmetic capabilities to a very limited subset of IEEE 754: Only one or two data types, no rounding modes, …
* Even if the developer would be proficient, most developing environments / technologies limit floating point arithmetic capabilities to a very limited subset of IEEE 754: Only one or two data types, no rounding modes, … [http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf]
* Results are hardly predictable. All operations produce the best possible accuracy ''at runtime'', this is how floating point works. Contrariwise, financial computer systems typically use a [http://en.wikipedia.org/wiki/Fixed-point_arithmetic fixed-point arithmetic] (COBOL, PL/I, …), where overflow and rounding can be precisely predicted ''at compile-time''.
* Results are hardly predictable. [https://hal.archives-ouvertes.fr/hal-00128124/en/] All operations produce the best possible accuracy ''at runtime'', this is how floating-point works. Contrariwise, financial computer systems typically use a [http://en.wikipedia.org/wiki/Fixed-point_arithmetic fixed-point arithmetic] (COBOL, PL/I, …), where overflow and rounding can be precisely predicted ''at compile-time''.
* If you do not know the technical details, cf. first bullet, you ignore the fact that the computer lies to you in many situations. For example, when looking at numerical output and the computer says “<code>ans = 0.1</code>,” this is not absolutely correct. In fact, the value is only ''close enough'' to the value 0.1.
* If you do not know the technical details, cf. first bullet, you ignore the fact that the computer lies to you in many situations. For example, when looking at numerical output and the computer says “<code>ans = 0.1</code>,” this is not absolutely correct. In fact, the value is only ''close enough'' to the value 0.1.


Line 67: Line 67:
  ans = [1, 1.0000000000000005]
  ans = [1, 1.0000000000000005]


Warning: Decimal fractions should always be passed as a string to the constructor. Otherwise it is possible, that GNU Octave introduces conversion errors when the numeric literal is converted into floating-point format '''before''' it is passed to the constructor.
Warning: Decimal fractions as well as numbers of high magnitude (> 2<sup>53</sup>) should always be passed as a string to the constructor. Otherwise it is possible, that GNU Octave introduces conversion errors when the numeric literal is converted into floating-point format '''before''' it is passed to the constructor.


  octave:9> infsup (<span style = "color:red">0.2</span>)
  octave:9> infsup (<span style = "color:red">0.2</span>)
Line 92: Line 92:
|-
|-
| com<br/>(common)
| com<br/>(common)
| ✓
| style="text-align: center" | ✓
| ✓
| style="text-align: center" | ✓
| ✓
| style="text-align: center" | ✓
| '''''x''''' is a bounded, nonempty subset of Dom(''f''); ''f'' is continuous at each point of '''''x'''''; and the computed interval ''f''('''''x''''') is bounded
| '''''x''''' is a bounded, nonempty subset of Dom(''f''); ''f'' is continuous at each point of '''''x'''''; and the computed interval ''f''('''''x''''') is bounded
|-
|-
| dac<br/>(defined &amp; continuous)
| dac<br/>(defined &amp; continuous)
|
|
| ✓
| style="text-align: center" | ✓
| ✓
| style="text-align: center" | ✓
| '''''x''''' is a nonempty subset of Dom(''f''); and the restriction of ''f'' to '''''x''''' is continuous
| '''''x''''' is a nonempty subset of Dom(''f''); and the restriction of ''f'' to '''''x''''' is continuous
|-
|-
Line 106: Line 106:
|
|
|
|
| ✓
| style="text-align: center" | ✓
| '''''x''''' is a nonempty subset of Dom(''f'')
| '''''x''''' is a nonempty subset of Dom(''f'')
|-
|-
Line 132: Line 132:


=== Arithmetic operations ===
=== Arithmetic operations ===
The interval packages comprises many interval arithmetic operations. Function names match GNU Octave standard functions where applicable, and follow recommendations by IEEE 1788 otherwise.
The interval packages comprises many interval arithmetic operations. Function names match GNU Octave standard functions where applicable, and follow recommendations by IEEE 1788 otherwise. It is possible to look up all functions by their corresponding IEEE 1788 name in the index {{Citation needed}}.


Arithmetic functions in a set-based interval arithmetic follow these rules: Intervals are sets. They are subsets of the set of real numbers. The interval version of an elementary function such as sin(''x'') is essentially the natural extension to sets of the corresponding point-wise function on real numbers. That is, the functions are evaluated for each number in the interval where the function is defined and the result must be an enclosure of all possible values that may occur.
Arithmetic functions in a set-based interval arithmetic follow these rules: Intervals are sets. They are subsets of the set of real numbers. The interval version of an elementary function such as sin(''x'') is essentially the natural extension to sets of the corresponding point-wise function on real numbers. That is, the function is evaluated for each number in the interval where the function is defined and the result must be an enclosure of all possible values that may occur.


One operation that should be noted is the <code>fma</code> function (fused multiply and add). It computes '''''x''''' * '''''y''''' + '''''z''''' in a single step and is much slower than multiplication followed by addition. However, it is more accurate and therefore preferred in some situations.
One operation that should be noted is the <code>fma</code> function (fused multiply and add). It computes '''''x''''' * '''''y''''' + '''''z''''' in a single step and is much slower than multiplication followed by addition. However, it is more accurate and therefore preferred in some situations.
Anonymous user