Changes

Jump to navigation Jump to search

Interval package

261 bytes added, 03:16, 8 March 2015
m
→‎Input and output: Added hint for command syntax
ans ⊂ [1, 1.0000000000000005]
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. In simple cases it may help to construct intervals with the [https://www.gnu.org/software/octave/doc/interpreter/Commands.html#Commands command syntax].
octave:9> infsup (<span style = "color:red">0.2</span>)
ans ⊂ [.20000000000000001, .20000000000000002]
octave:10> infsup (<span style = "color:green">"0.2"</span>)
ans ⊂ [.19999999999999998, .20000000000000002]
octave:11> infsup <span style = "color:green">0.2</span>
ans ⊂ [.19999999999999998, .20000000000000002]
For convenience it is possible to implicitly call the interval constructor during all interval operations if at least one input already is an interval object.
octave:1112> infsup ("17.7") + 1
ans ⊂ [18.699999999999999, 18.700000000000003]
octave:1213> ans + "[0, 2]"
ans ⊂ [18.699999999999999, 20.700000000000003]
** <code>''E ''</code> is either empty or an exponent field comprising the character <code>e</code> followed by a decimal integer exponent (base 10).
octave:1314> infsup ("0x1.999999999999Ap-4")
ans ⊂ [.1, .10000000000000001]
octave:1415> infsup ("1/3", "7/9")
ans ⊂ [.33333333333333331, .7777777777777778]
octave:1516> infsup ("121.2?")
ans ⊂ [121.14999999999999, 121.25]
octave:1617> infsup ("5?32e2")
ans = [-2700, +3700]
octave:1718> infsup ("-42??u")
ans = [-42, +Inf]
==== Interval vectors and matrices ====
Vectors and matrices of intervals can be created by passing numerical matrices, char vectors or cell arrays to the <code>infsup</code> constructor. With cell arrays it is also possible to mix several types of boundaries.
octave:1819> M = infsup (magic (3))
M = 3×3 interval matrix
[4] [9] [2]
octave:1920> infsup (magic (3), magic (3) + 1)
ans = 3×3 interval matrix
[4, 5] [9, 10] [2, 3]
octave:2021> infsup (["0.1"; "0.2"; "0.3"; "0.4"; "0.5"])
ans ⊂ 5×1 interval vector
[.5]
octave:2122> infsup ({1, eps; "4/7", "pi"}, {2, 1; "e", "0xff"})
ans ⊂ 2×2 interval matrix
When matrices are resized using subscripted assignment, any implicit new matrix elements will carry an empty interval.
octave:2223> M (4, 4) = 42
M = 4×4 interval matrix
Note: Whilst most functions (<code>size</code>, <code>isvector</code>, <code>ismatrix</code>, …) work as expected on interval data types, the function <code>'''isempty'''</code> is evaluated element-wise and checks if an interval equals the empty set.
octave:2324> builtin ("isempty", empty ()), isempty (empty ())
ans = 0
ans = 1
240

edits

Navigation menu