I will present two solutions, a hard (and not quite complete) one and an easy (but undocumented) one. First, the hard one.
- Use
Interval[real]
to determine the default widening.
Consider:
r = 1.23`2;
(int = Interval[r]) //InputForm
Interval[{1.214375`1.9944477065044612, 1.245625`2.0054822046051672}]
Note how an Interval
object is created that includes the input r
. Now, for the key observation: Repeat the above procedure with the end points:
{left, right} = First @ int;
Interval[left] //InputForm
Interval[right] //InputForm
Interval[{1.19875`1.988823508739323, 1.23`2.}]
Interval[{1.23`2., 1.26125`2.0108960678055694}]
Notice how the original input r
reappears. So, the basic algorithm to create the desired output is:
PreciseInterval[{l_, r_}] := Interval[{Interval[l][[1,2]], Interval[r][[1,1]]}]
For example:
PreciseInterval[{1.2`3, 3.3`5}] //InputForm
Interval[{1.2`3., 3.3`5.}]
The only problem is that this algorithm doesn't work when the end point generated by Interval
is an arbitrary precision 0. For example:
Interval[.1`.2] //InputForm
Interval[{0``1.2, 0.225`0.5521825181113625}]
In this case, PreciseInterval
gives:
PreciseInterval[{-1, .1`.2}] //InputForm
Interval[{-1, 0.1000000000000000056`0.4259697322722812}]
which isn't bad. It is possible to do slightly better, but instead, let's turn to the easy method.
- The easy (but undocumented) option
The issue would be moot if one could figure out a way to create an "evaluated" Interval
object without having the Interval
object actually evaluate. And, there is a way to do this! The needed function is System`Private`HoldSetValid
. The function System`Private`HoldSetValid
tells Mathematica that its argument has already been evaluated, so Mathematica need not try to evaluate it again. Using this function:
Clear[PreciseInterval]
PreciseInterval[{a_, b_}] := System`Private`HoldSetValid[Interval[{a, b}]]
Let's check the previous example:
PreciseInterval[{-1, .1`.2}]//InputForm
Interval[{-1, 0.1`0.2}]