240
edits
m (Converted Latex markup into mediawiki markup) |
|||
Line 45: | Line 45: | ||
=== Input and output === | === Input and output === | ||
Before exercising interval arithmetic, interval objects must be created, typically from non-interval data. There are interval constants <code>empty</code> and <code>entire</code> and the class constructors <code>infsup</code> for bare intervals and <code>infsupdec</code> for decorated intervals. The class constructors are very sophisticated and can be used with several kinds of parameters: Interval boundaries can be given by numeric values or string values with decimal numbers. Also it is possible to use so called interval literals with square brackets. | |||
octave:1> infsup (1) | |||
ans = [1] | |||
octave:2> infsup (1, 2) | |||
ans = [1, 2] | |||
octave:3> infsup ("3", "4") | |||
ans = [3, 4] | |||
octave:4> infsup ("1.1") | |||
ans = [1.0999999999999998, 1.1000000000000001] | |||
octave:5> infsup ("[5, 6.5]") | |||
ans = [5, 6.5] | |||
octave:6> infsup ("[5.8e-17]") | |||
ans = [5.799999999999999e-17, 5.800000000000001e-17] | |||
It is possible to access the exact numeric interval boundaries with the functions <code>inf</code> and <code>sup</code>. The default text representation of intervals can be created with <code>intervaltotext</code>. The default text representation is not guaranteed to be exact (see function <code>intervaltoexact</code>), because this would massively spam console output. For example, the exact text representation of <code>realmin</code> would be over 700 decimal places long! However, the default text representation is correct as it guarantees to contain the actual boundaries and is accurate enough to separate different boundaries. | |||
octave:7> infsup (1, 1 + eps) | |||
ans = [1, 1.0000000000000003] | |||
octave:8> infsup (1, 1 + 2 * eps) | |||
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. | |||
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] | |||
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:11> infsup ("17.7") + 1 | |||
ans = [18.699999999999999, 18.700000000000003] | |||
octave:12> ans + "[0, 2]" | |||
ans = [18.699999999999999, 20.700000000000003] | |||
=== Decorations === | === Decorations === |
edits