Next: , Previous: , Up: Top   [Contents]


3 Examples

This chapter presents some more or less exotic use cases for the interval package.

3.1 Arithmetic with System-independent Accuracy

According to IEEE Std 754 only the most basic floating-point operations must be provided with high accuracy. This is also true for the arithmetic functions in Octave. It is no surprise that many arithmetic functions fail to provide perfect results and their output may be system dependent.

We compute the cosecant for 100 different values.

x = vec (1 ./ magic (10));
sum (subset (csc (x), csc (infsupdec (x))))
  ⇒ ans =  98

Due to the general containment rule of interval arithmetic x ∈ X ⇒ f (x) ∈ f (X) one would expect the csc (x) to always be contained in the interval version of the cosecant for the same input. However, the classic cosecant is not very accurate whereas the interval version is. In 2 out 100 cases the built-in cosecant is less accurate than 1 ULP.

3.2 Prove the Existence of a Fixed Point

A weaker formulation of Brower’s fixed-point theorem goes: If x is a bounded interval and function f is continuous and f (x) ⊂ x, then there exists a point x₀ ∈ x such that f (x₀) = x₀.

These properties can be tested automatically. Decorated intervals can even prove that the function is continuous.

x = infsupdec ("[-1, +1]");
f = @cos;
subset (f (x), x)
  ⇒ ans =  1
iscommoninterval (x)
  ⇒ ans =  1
continuous = strcmp (decorationpart (f (x)), "com")
  ⇒ continuous =  1

Furthermore it is sometimes possible to approximate the fixed-point by repetitive evaluation of the function, although there are better methods to do so in general.

for i = 1 : 20
    x = f (x);
endfor
display (x)
  ⇒ x ⊂ [0.73893, 0.73919]_com

Next: , Previous: , Up: Top   [Contents]