Skip to content

Commit 0f54013

Browse files
authored
Fix typos in philosophy.md
1 parent ae454b2 commit 0f54013

File tree

1 file changed

+39
-24
lines changed

1 file changed

+39
-24
lines changed

docs/src/philosophy.md

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
# Philosophy
22

33
The goal of the `Interval` type is to be directly used to replace floating point
4-
number in arbitrary julia code, such that in any calculation,
5-
the resulting intervals are guaranteed to bound the true image of the starting
4+
numbers in arbitrary julia code, such that, in any calculation,
5+
the resulting interval is guaranteed to bound the true image of the starting
66
intervals.
77

8-
So, essentially, we would like `Interval` to act as numbers and
9-
the julia ecosystem has evolved to use `Real` as the default supertype
8+
So, essentially, we would like `Interval` to act as numbers.
9+
And the julia ecosystem has evolved to use `Real` as the default supertype
1010
for numerical types that are not complex.
1111
Therefore, to ensure the widest compatiblity,
1212
our `Interval` type must be a subtype of `Real`.
1313

14-
Then, for any function `f(x::Real)`,
15-
we want the following to hold for all real `x` in the interval `X`
14+
Mathematically, for any function `f(x::Real)`,
15+
we want the following to hold
1616
(note that it holds for **all** real numbers in `X`,
17-
even those that can not be represented as floating point numbers):
17+
even those that cannot be represented as floating point numbers):
1818
```math
1919
f(x) \in f(X), \qquad \forall x \in X.
2020
```
21+
The interval-valued function `f(X)` is called
22+
the _pointwise extension_ of `f(x)` (which is defined on real numbers).
2123

2224
At first glance, this is reasonable:
2325
all arithmetic operations are well-defined for both real numbers and intervals,
@@ -34,7 +36,7 @@ arithmetic operations.
3436
3. Act as a container of a single element,
3537
e.g. `collect(x)` returns a 0-dimensional array containing `x`.
3638

37-
Each of those points lead to specific design choice for `IntervalArithmetic.jl`,
39+
Each of those points lead to specific design choices for `IntervalArithmetic.jl`,
3840
choices that we detail below.
3941

4042

@@ -46,53 +48,65 @@ to a `Float64` to be able to perform the addition.
4648
Following this logic, it means that `0.1 + interval(2.2, 2.3)` should
4749
silently promote `0.1` to an interval.
4850

49-
However, in this case we can not guarantee that `0.1` is known exactly,
50-
because we do not know how it was produced in the first place.
51+
However, in this case we cannot guarantee that `0.1` is known exactly,
52+
because we do not know how it was produced in the first place
53+
(it could be contain numerical inaccuracy from another computation from example).
5154
Following the julia convention is thus in contradiction with providing
5255
guaranteed result.
5356

5457
In this case, we choose to be mostly silent,
5558
the information that a non-interval of unknown origin is recorded in the `NG` flag,
5659
but the calculation is not interrupted, and no warning is printed.
60+
If an interval is flagged with `NG` it means that it was produced through
61+
promotion of real numbers from unknown origin, for example
62+
```julia
63+
julia> X = interval(1, 2)
64+
[1.0, 2.0]_com # The interval is guaranteed because it was explicitly created
65+
66+
julia> X + 0.1
67+
[1.1, 2.1]_com_NG # The NG flag appears, because 0.1 is not provably exact
68+
```
5769

5870
For convenience, we provide the [`ExactReal`](@ref) and [`@exact`](@ref) macro
59-
to allow to explicitly mark a number as being exact,
71+
to allow explicitly marking a number as being exact,
6072
and not produce the `NG` flag when mixed with intervals.
6173

74+
Note that this still assume that all interval inputs are correct.
75+
Please see the [contructors page](@ref "Constructing intervals") for more information
76+
about potential caveats.
6277

6378

6479
## Comparison operators
6580

66-
We can extend our above definition of the desired behavior for two real numbers
67-
`x` and `y`, and their respective intervals `X` and `Y`.
68-
With this, we want to have, for any function`f`,
69-
for all `x` in `X` and all `y` in `Y`,
70-
``math
81+
We can extend the definition of the pointwise extension of a function `f` for two real numbers
82+
`x` and `y`, and their respective intervals `X` and `Y`, as
83+
```math
7184
f(x, y) \in f(X, Y), \qquad \forall x \in X, y \in Y.
72-
``
85+
```
7386

7487
With this in mind, an operation such as `==` can easily be defined for intervals
7588

7689
1. If the intervals are disjoints (`X ∩ Y === ∅`), then `X == Y` is `[false]`.
77-
2. If the intervals both contain a single element,
90+
2. If the intervals both contain a single floating point number,
7891
and that element is the same for both,
7992
`X == Y` is `[true]`.
8093
3. Otherwise, we can not conclude anything, and `X == Y` must be `[false, true]`.
8194

82-
Not that we use intervals in all case, because, according to our definition,
95+
Not that we use intervals for all outputs, because, according to our definition,
8396
the true result must be contained in the returned interval.
8497
However, this is not convenient, as any `if` statement would error when used
8598
with an interval.
8699
Instead, we have opted to return respectively `false` and `true`
87100
for cases 1 and 2, and to immediately error otherwise.
88101

89102
In this way, we can return a more informative error,
90-
but we only do it when the result is ambiguous.
103+
but we only error when the result is ambiguous.
91104

92105
This has a clear cost, however, in that some expected behaviors do not hold.
93106
For example, an `Interval` is not equal to itself.
94107

95-
```julia> X = interval(1, 2)
108+
```julia
109+
julia> X = interval(1, 2)
96110
[1.0, 2.0]_com
97111

98112
julia> X == X
@@ -133,9 +147,10 @@ or error as the result can not be established.
133147
To be safe, we decided to go one step further and disable
134148
**all** set operations from julia `Base` on intervals.
135149
These operations can instead be performed with the specific `*_interval` function,
136-
for example `in_interval` as a replacement for `in`,
137-
except for `setdiff`.
138-
We can not meaningfully define the set difference of two intervals,
150+
for example `in_interval` as a replacement for `in`.
151+
152+
`setdiff` is an exception,
153+
as we can not meaningfully define the set difference of two intervals,
139154
because our intervals are always closed,
140155
while the result of `setdiff` can be open.
141156

0 commit comments

Comments
 (0)