Thread Links | Date Links | ||||
---|---|---|---|---|---|
Thread Prev | Thread Next | Thread Index | Date Prev | Date Next | Date Index |
Vincent and wg1788, I changed "difficult" to "accuracy-relaxed". I failed to formulate concisely your suggestion. Instead I added such a requirement. If the result of textToInterval(s) constructor is wider than the hull of Level 1 value of s then exception shall be signaled. So application is warned about relaxed accuracy of implementation. The modified text is in the attachment. -Dima ----- Original Message ----- From: vincent@xxxxxxxxxx To: stds-1788@xxxxxxxxxxxxxxxxx Sent: Thursday, October 6, 2016 5:32:47 PM GMT +03:00 Iraq Subject: Re: Motion M006.01: discussion period begins, until October 17 On 2016-10-05 08:39:34 -0700, Dmitry Nadezhin wrote: > Vincent, > > > I don't like the word "difficult" in this context, because it > > may not actually be difficult. I would rather use a word like > > "advanced" / "enhanced" / "extended". > > Do you like a word "accuracy-relaxed string" ? This is beter, IMHO. > > In §6.7.5, I would replace "any interval" by constraints obtained > > with a basic algorithm to have a reasonable behavior, such as: I think that there was an error in (2). It was: 2. If L < U, then return the hull of x. It should be like (4), i.e. one should have: 2. If l <= u, return any interval I such that [l,u] included in I included in hull(L,U). The only difference is that this is a bit relaxed with rational literal bounds. But since L < U implies l <= u (used in (4)), one can remove (2) entirely. I hope that this is now correct. > I like your suggestion about L and U. > What will your rules say about semi-infinite interval with rational > bound like "[p/q, +inf]" ? This should be similar to the corrected (2) and (4) where U = [l,+oo). > I think that U is not relevant here and it should return I such that > [p/q, +oo) included in I include in [hull(hull(p)/hull(q)), +oo). I suppose that you meant: [inf(hull(hull(p)/hull(q))), +oo) But saying that U = [l,+oo) is simpler and avoids a dependency on the rules from (1). -- Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Attachment:
level2a.pdf
Description: Adobe PDF document
% !TEX root = P1788_1_MAIN.tex %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\btype}{\@b64@} \newcommand{\itype}{$\T$} \newcommand{\nadrm}[1]{{\color{red}#1}} \newcommand{\nadadd}[1]{{\color{blue}{#1}}} \newpage \section{Level 2 description}\Blabel{sc:level2} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Introduction}\Blabel{ss:level2intro}~ Entities and operations at Level 2 are said to have {\bf finite precision}. From them, implementable interval algorithms may be constructed. Level 2 entities are called {\bf datums}% \footnote{Not ``data'', whose common meaning could cause confusion.}.% \medskip \subsubsection{Interval type} ~ % {The interval type, denoted by \itype, is the {\bf inf-sup type} derived from the \ieeefp \@binary64@ format; we refer to the latter as \@b64@. This interval type comprises all intervals whose endpoints are \bform numbers, together with \Emp.} {Since $\pm\infty$ are in $\bform$, \Ent is in $\Tis$. } {An interval from $\Tis$ is also called a {\bf bare interval} or a {\bf $\T$-interval}. We use the term {\bf $\T$-datum} to refer to an entity that can be a {$\T$-interval} or a \nai.} A {\bf $\T$-box} is a vector with {$\T$-datum} components. \medskip \subsubsection{Decorated interval type}~ {The decorated interval type, derived from $\Tis$, is the set of tuples $(x,d)$, where $x\in \Tis$, and $d\in \D$. We denote this type by $\DTis$.} $\DTis$ shall contain a ``Not an Interval'' datum \nai, which is identified with $(\emp,\Dill)$. \medskip \subsubsection{Operations} ~ The term {\bf $\T$-version} of a Level 1 operation denotes one in which any input or output that is an interval is a $\T$-datum. For \bintvl types this includes the following. \begin{enumerate}[--] \item An interval extension (see \ssrf{lvl2bintvlextn}) of one of the \arops of \ssrf{lvl1reqd-ops}. \item A set operation, such as intersection and convex hull of $\T$-intervals, returning a $\T$-interval. \item A function such as the midpoint, whose input is a $\T$-interval and output is numeric. \item A constructor, whose input is numeric or text and output is a $\T$-datum. \end{enumerate} \medskip \subsubsection{Exception behavior}~\Blabel{ss:lvl2excbehavior} For some operations, and some particular inputs, there might not be a valid result. At Level 1 there are several cases when no value exists. However, a Level 2 operation always returns a value. When the Level 1 result does not exist, the corresponding Level 2 operation returns either \begin{itemize} \item a special value indicating this event (e.g., \nan for most of the numeric functions in \ssrf{lvl2reqdnumintvlfns}); or \item a value considered reasonable in practice. % For example, $\name{mid}(\Ent)$ returns $0$; a constructor given invalid input returns \Emp; and one of the comparisons of \ssrf{lvl2reqdboolintvlfns}, if any input is \nai, returns \name{false}. \end{itemize} %The standard defines the following {\bf exceptions} that may be signaled, causing a handler to be invoked: %\begin{itemize} % \item For the interval constructors of \ssrf{lvl2bintvlconstructors}, and for \name{exactToInterval} in \ssrf{lvl2io-exact}, it is possible that at Level 2, using finite precision, the implementation cannot decide whether a Level 1 value exists or not, see {\sf\em Difficulties in implementation} in \ssrf{lvl2bintvlconstructors}. % If the constructor is certain that no Level 1 value exists, the exception \name{IntvlConstructorFails} is signaled; if it cannot decide, the exception \name{IntvlConstructorUnsure} is signaled. % \item If $\name{intervalPart}()$ is called with \nai as input, the exception \name{IntvlPartOfNaI} is signaled, see \ssrf{lvl2excbaredecops}. %\end{itemize} If $\name{intervalPart}()$ is called with \nai as input, the exception \name{IntvlPartOfNaI} is signaled (see \ssrf{lvl2excbaredecops}). If a bare or decorated constructor fails (see \S\Bref{ss:lvl2bintvlconstructors}) the exception \name{UndefinedOperation} is signaled. % nad % \S\Bref{ss:lvl2reqdnumintvlfns}) the exception \name{UndefinedOperation} is signaled. \nadadd{If a bare or decorated constructor succeeds on a accuracy-relaxed string argument (see \S\Bref{ss:lvl2bintvlconstructors}) the exception\linebreak \name{PossiblyUndefinedOperation} may be signaled.} \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Naming conventions for operations}~\Blabel{ss:lvl2namingops} An operation is generally given a name that suits the context. For example, the addition of two interval datums $\~x,\~y$ may be written in generic algebra notation $\~x+\~y$; or with a generic text name $\name{add}(\~x,\~y)$. \pagebreak %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Level 2 hull operation}\Blabel{ss:lvl2bintvlhull} \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsubsection{Hull in one dimension}~\Blabel{ss:lvl2bintvlhull1d} The {\bf interval hull} operation \[ \~y = \hull(\~s), \] maps an arbitrary set of reals $\~s$ to the tightest interval $\~y$ enclosing $\~s$. \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsubsection{Hull in $n$ dimensions}~ In $n$ dimensions the \hull, as defined mathematically in \ssrf{lvl2bintvlhull1d}, is extended to act componentwise. That is, for an arbitrary subset $\~s$ of $\R^n$ it is $\hull(\~s) = (\~y_1,\ldots,\~y_n)$, where \[ \~y_i = \hull(\~s_i), \] and $\~s_i = \set{s_i}{$s\in\~s$}$ is the projection of $\~s$ on the $i$th coordinate dimension. \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Level~2 interval extensions}~\Blabel{ss:lvl2bintvlextn} Let $f$ be an $n$-variable scalar point function. A {\bf $\T$-interval extension} of $f$, also called a {\bf $\T$-version} of $f$, is a mapping $\~f$ from $n$-dimensional $\T$-boxes to $\T$-intervals, that is $\~f:\T^n\to\T$, such that $f(x)\in\~f(\~x)$ whenever $x\in\~x$ and $f(x)$ is defined. % Equivalently \begin{align*}%\Blabel{eq:lvl2bintvlop1} \~f(\~x) \supseteq \range(f|\~x), \end{align*} for any $\T$-box $\~x\in\T^n$, regarding $\~x$ as a subset of $\R^n$. Generically, such mappings are called Level~2 interval extensions. %Though only defined over a finite set of boxes, a Level 2 extension of $f$ is equivalent to a full Level 1 extension of $f$ (\ssrf{lvl1i-functions}) so that this document does not distinguish between Level 2 and Level 1 extensions. Namely define $\~f^*$ by %\[ \~f^*(\~s) = \~f(\hull\nedrm{_\T}(\~s)) \] %for any subset $\~s$ of $\R^n$. Then the interval $\~f^*(\~s)$ contains $\range(f|\~s)$ for any $\~s$, making $\~f^*$ a Level~1 extension, and $\~f^*(\~s)$ equals $\~f(\~s) $ whenever $\~s$ is a $\T$-box. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Accuracy of operations}~\Blabel{ss:lvl2bintvlacc} {\newcommand\fexact{\~f_{\text{exact}}} \newcommand\ftightest{\~f_{\text{tightest}}} This subclause describes requirements and recommendations on the accuracy of operations. Here, {\em operation} denotes any Level 2 version, provided by the implementation, of a Level 1 operation with interval output and at least one interval input. Bare interval operations are described; the accuracy of a decorated operation is defined to be that of its interval part. \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsubsection{Measures of accuracy}~\Blabel{ss:lvl2accmeas} Three {\bf accuracy modes} are defined that indicate the quality of interval enclosure achieved by an operation: \tightest, \accurate and \valid in order from strongest to weakest. %Each mode is in the first instance a property of an individual evaluation of an operation $\~f$ over an input box $\~x$. The term {\bf tightness} means the strongest mode that holds uniformly for some set of evaluations. For example, for some one-argument function, an implementation might document the tightness of $\~f(\~x)$ as being \tightest for all $\~x$ contained in $[-10^{15},10^{15}]$ and at least \accurate for all other $\~x$. Let $\fexact$ denote the corresponding Level 1 operation. % and, for a forward or reverse \arop, let $f$ be the underlying point function% %\footnote{Non-interval arguments, such as the $p$ of $\name{pown}(\~x,p)$, are ignored in the following.}. The weakest mode \valid is just the property of enclosure: \begin{align}\Blabel{eq:lvl2bintvlop2} \~f(\~x) \supseteq \fexact(\~x). \end{align} The strongest mode \tightest is the property that $\~f(\~x)$ equals $\ftightest(\~x)$, the hull of the Level~1 result: \begin{align}\Blabel{eq:lvl2bintvlop3} \ftightest(\~x) = \hull \bigl(\fexact(\~x)\bigr). \end{align} %For a forward \arop, it is equivalent to %\begin{align}\Blabel{eq:lvl2bintvlop4} % \~f(\~x) = \hull_\T(\range(f|\~x)). %\end{align} The intermediate mode \accurate asserts that $\~f(\~x)$ is \valid, \rf{lvl2bintvlop2}, and is at most slightly wider than the result of applying the \tightest version to a slightly wider input box: \begin{align}\Blabel{eq:lvl2bintvlop5} \~f(\~x) \subseteq \name{nextOut}\left(\ftightest\left(\name{nextOut}\bigl(\hull(\~x)\bigr)\right)\right). \end{align} For an interval $\~x$, \begin{align*}%\Blabel{eq:lvl2bintvlop6} \name{nextOut}(\~x) = \stackcl{ $[\,\name{nextDown}(\ul{x}),\,\name{nextUp}(\ol{x})\,]$ & if $\~x=\uo{x}\ne\emp$, \\ $\emp$ & if $\~x=\emp$, } \end{align*} where \name{nextUp} and \name{nextDown} are equivalent to the corresponding functions in \ieeefp. When $\~x$ is an interval box, \name{nextOut} acts componentwise. %\notenum1{ %\nedrm{For a \ieeefp format, \name{nextUp} and \name{nextDown} are equivalent to the corresponding functions in \Ieeefp-2008 \S5.3.1.} %} \note{In \rf{lvl2bintvlop5}, the inner $\name{nextOut}()$ aims to handle the problem of a function such as $\sin x$ evaluated at a very large argument, where a small relative change in the input can produce a large relative change in the result. The outer $\name{nextOut}()$ relaxes the requirement for correct (rather than, say, faithful) rounding, which might be hard to achieve for some special functions at some arguments. } \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsubsection{Accuracy requirements}~ %%This follows Motion 49, which passed nem con: Following the categories of functions in \tbref{ch1reqdfwdelemfuns}, the accuracy of the {\em basic operations}, the {\em integer functions} and the {\em absmax functions} shall be \tightest. The accuracy of the {\em cancellative addition and subtraction} operations of \ssrf{lvl1cancelminus} is specified in \ssrf{lvl2cancelminus}. For all other operations in \tbref{ch1reqdfwdelemfuns}, the accuracy should be \accurate. \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsubsection{Documentation requirements}~ An implementation shall document the tightness of each of its interval operations. This shall be done by dividing the set of possible inputs into disjoint subsets (``ranges'') and stating a tightness achieved in each range. \example{Sample tightness information for the $\sin$ function might be \bc \begin{tabular}{lll} Operation & Tightness & \multicolumn{1}{c}{Range} \\\hline\rule{0em}{2.5ex} \multirow{2}{*}{$\sin$} &\tightest &for any $\~x\subseteq[-10^{15},10^{15}]$ \\ & \accurate &for all other $\~x$. \end{tabular} \ec } \medskip Each operation should be identified by a \LIdefd name of the Level 1 operation (which might differ from that used in this standard), its output type, its input type(s) if necessary, and any other information needed to resolve ambiguity. } \medskip \subsection{Number and interval literals} \Blabel{ss:lvl2bintvlliteral}~ {%start definitions for subsection \newcommand\ulp{\mbox{\tt ulp}\xspace} %Definitions for grammar. \newcommand\M[1]{\mbox{\tt#1}} %for metacharacter like * + ? %To highlight metacharacters, activate the next command instead: %\newcommand\M[1]{\mbox{\color{red}\tt#1}} %for metacharacter like * + ? \newcommand\C[1]{\mbox{\tt\M[#1\M]}} %for character-list [...] notation \newcommand\Trm[1]{\mbox{\sf#1}} %term defined on LHS \newcommand\trm[1]{\,\M\{\mbox{\sf#1}\M\}\,} %term referred to on RHS \renewcommand\L[1]{\mbox{\tt"#1"}} %for literal string in quotes \newcommand\TAB{\lstinline{\\t}} \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsubsection{Number literals}\Blabel{ss:lvl2numlit}~ % % % The following forms of number literal shall be provided. \begin{enumerate}[a)] % nad %\begin{enumerate}[--] \item\Blabel{it:nlit1} A decimal number. This comprises an optional sign, a nonempty sequence of decimal digits optionally containing a point, and an optional exponent field comprising \@e@ and an integer literal.\footnote{An integer literal comprises an optional sign and followed by a nonempty sequence of decimal digits.} The value of a decimal number is the value of the sequence of decimal digits with optional point multiplied by ten raised to the power of the value of the integer literal, negated if there is a leading \@-@ sign. \item\Blabel{it:ch1nlithex} A number in the hexadecimal-floating-constant form of the C99 standard (ISO/IEC9899, N1256 (6.4.4.2)), equivalently hexadecimal-significand form of \Ieeefp (5.12.3). This comprises an optional sign, the string \@0x@, a nonempty sequence of hexadecimal digits optionally containing a point, and an exponent field comprising \@p@ and an integer literal exponent. The value of a hexadecimal number is the value of the sequence of hexadecimal digits with optional point multiplied by two raised to the power of the value of the exponent, negated if there is a leading minus sign. \nadadd{\item\Blabel{it:nlitrat} A rational literal \@$p$\,/\,$q$@. This comprises an integer literal $p$, the \@/@ character, and a positive-natural literal $q$. Its value is the value of $p$ divided by the value of $q$.} \item\Blabel{it:nlit2} Either of the strings \@inf@ or \@infinity@ optionally preceded by \@+@, with value $\pinf$; or preceded by \@-@, with value $\ninf$. \end{enumerate} \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsubsection{Bare intervals}\Blabel{ss:lvl2bintvllit}~ % The following forms of \bintvl literal shall be supported. Below, the number literals $l$ and $r$ are identified with their values. Space shown between elements of a literal denotes zero or more space characters. \begin{enumerate}[--] \item A string \@[\;$l$\;,\;$u$\;]@ where $l$ and $u$ are optional number literals \nadrm{of the same radix (10 or 16)} with $l\le u$, $l<\pinf$ and $u>\ninf$, see \ssrf{lvl1intervals}. Its bare value is the mathematical interval $[l,u]$. Any of $l$ and $u$ may be omitted, with implied values $l=\ninf$ and $u=\pinf$, respectively; e.g. \@[,]@ denotes Entire. \\ A string \@[\;$x$\;]@ is equivalent to \@[\;$x$\;,\;$x$\;]@. \nadadd{\item Uncertain form: a string \@$m$\;?\;$r$\;$v$\;$E$@ where: $m$ is a decimal number literal of form \itref{nlit1} in \ssrf{lvl2numlit}, without exponent; $r$ is empty or is a natural-number literal {\em ulp-count} or is $?$; %or is the \@?@ character; $v$ is empty or is a {\em direction character}, either \@u@ (up) or \@d@ (down); and $E$ is empty or is an {\em exponent field} comprising the character \@e@ followed by an integer literal {\em exponent} $e$. No whitespace is permitted within the string. With \ulp meaning $10^{-d}$ where $d$ is the number of digits after the decimal point in $m$ (or 0 if there is no decimal point), the literal \@$m$?@ by itself denotes $m$ with a symmetrical uncertainty of half an ulp, that is the interval $[m-\frac12\ulp, m+\frac12\ulp]$. The literal \@$m$?$r$@ denotes $m$ with a symmetrical uncertainty of $r$ ulps, that is $[m-r\x\ulp, m+r\x\ulp]$. Adding \@d@ (down) or \@u@ (up) converts this to uncertainty in one direction only, e.g., \@$m$?d@ denotes $[m-\frac12\ulp, m]$ and \@$m$?$r$u@ denotes $[m, m+r\x\ulp]$. Uncertain form with radius \@?@ is for unbounded intervals, e.g., \@$m$??d@ denotes $[\ninf, m]$. The exponent field if present multiplies the whole interval by $10^e$, e.g., \@$m$\,?$r$u\,e$e$@ denotes $10^e\x[m, m+r\x\ulp]$.} \item Special values: the strings \@[\;]@ and \@[\;empty\;]@, whose bare value is \Emp , and the string \@[\;entire\;]@, whose bare value is \Ent . % \end{enumerate} \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsubsection{Decorated intervals}\Blabel{ss:lvl2dintvllit}~ % %A \dintvl literal may denote either a bare or a \dintvl value depending on context. The following forms of \dintvl literal shall be supported. \begin{enumerate}[--] \item $\~{sx}\verb`_`\~{sd}$: a \bintvl literal $\~{sx}$, an underscore ``\verb`_`'', and a 3-character decoration string $\~{sd}$, where $\~{sd}$ is one of \Dtrv, \Ddef, \Ddac or \Dcom, denoting the corresponding decoration $dx$. If $\~{sx}$ has the bare value $\~x$, and if $\~x_{dx}$ is a permitted combination according to \ssrf{lvl1excpermit}, then $\~{sx}\verb`_`\~{sd}$ has the value $\~x_{dx}$. Otherwise $\~{sx}\verb`_`\~{sd}$ has no value as a \dintvl literal. % \item The string \@[\;nai\;]@, with the bare value $\Emp$ and the decorated value $\Emp_\Dill$. \end{enumerate} \smallskip % The alphanumeric characters in the above literals are case-insensitive (e.g., \li{[1,1e3]_com} is equivalent to \li {[1,1E3]_COM}). %It is assumed here that they have been converted to lowercase. %By default number syntax shall be that of the default locale (C locale); locale-specific variants may be provided. \medskip % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Required operations}~ \Blabel{ss:lvl2bintvlops} % Operations in this subclause are described as functions with zero or more input arguments and one return value. It is \Ldefd whether they are implemented in this way.% \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsubsection{Interval constants}~ \Blabel{ss:lvl2bintvlreqdconst} There shall be functions $\name{empty}()$ and $\name{entire}()$ returning an interval with value \Emp and \Ent, respectively. % There shall also be a decorated version of each, returning $$\name{newDec}(\Emp) = \Emp_\Dtrv \quad\text{and}\quad\name{newDec}(\Ent)=\Ent_\Ddac,$$ respectively. \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsubsection{Elementary functions}~ \Blabel{ss:lvl2bintvlopfwd} An implementation shall provide an interval version of each \arop in Table \Bref{tb:ch1reqdfwdelemfuns}. Its inputs and output are intervals, and it shall be a Level~2 interval extension of the corresponding point function. Recommended accuracies are given in \ssrf{lvl2bintvlacc}. \note{For operations, some of whose arguments are of integer type, such as integer power $\name{pown}(x,p)$, only the real arguments are replaced by intervals.} Each such operation shall have a decorated version with corresponding arguments of type $\DT$. It shall be a \dintvl extension as defined in \ssrf{lvl1excdecIE}---thus the interval part of its output is the same as if the \bintvl operation were applied to the interval parts of its inputs. The only freedom of choice in the decorated version is how the local decoration, denoted $dv_0$ in \rf{lvl1excdeclocal} of \ssrf{lvl1excdecIE}, is computed. $dv_0$ shall be the strongest possible (and is thus uniquely defined), if the accuracy mode of the corresponding \bintvl operation is ``tightest'', but otherwise is only required to obey \rf{lvl1excdeclocal}. \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsubsection{Cancellative addition and subtraction} ~\Blabel{ss:lvl2cancelminus} An implementation shall provide a $\T$-version of each of the operations \name{cancelMinus} and \name{cancelPlus} in \ssrf{lvl1cancelminus}. Their inputs and output are $\T$-intervals. $\name{cancelMinus}(\~x,\~y)$ shall return \Emp in the first case of \rf{cancelminus1}, the hull of the result in the second, and \Ent for each of the cases in \rf{cancelminus2}. $\name{cancelPlus}(\~x,\~y)$ shall be equivalent to $\name{cancelMinus}(\~x,-\~y)$. These operations shall have ``trivial'' decorated versions, as described in \ssrf{lvl1excnonarops}. %\note{Two cases need care. Examples are given where $\T$ is the inf-sup type of a format $\F$. %\notes{Two cases need care: see \scrf{annexinnerops} for more detail. Examples are given where $\T$ is the inf-sup type of a format $\F$. %\begin{itemize} % \item Determining whether the Level 1 value is defined needs care when $\~x$ and $\~y$ have equal widths in finite precision. An example is $\name{cancelMinus}([-1,a],[-b,1])$ where $a$ and $b$ are positive $\F$-numbers less than $\F$'s roundoff unit, where the latter is the smallest positive $\F$-number $u$ for which the computed value of $1+u$ is greater than 1. % \item For any $\~x,\~y$, the Level 1 result is always bounded when it is defined, but might overflow at Level 2. An example is $\name{cancelMinus}([M,M],[-M,-M])$ where $M$ is the largest finite $\F$-number. The exact value is $[2M,2M]$, whose $\T$-hull is $[M,\pinf]$. % An implementation should not return \Ent in case of overflow. % For any inf-sup type it can avoid doing so, since the Level 1 result has width not exceeding that of $\~x$, and therefore at Level 2 cannot overflow to both $\ninf$ and $\pinf$. Not returning \Ent in case of overflow makes the result \Ent diagnostic: it occurs if, and only if, there is no value at Level 1. %\end{itemize} %} \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsubsection{Set operations}~ \Blabel{ss:lvl2bintvlsetops} An implementation shall provide an interval version of each of the operations \name{intersection} and \name{convexHull} in \ssrf{lvl1reqdsetops}. Its inputs and output are intervals. % These operations should return the interval hull of the exact result. If either input to \name{intersection} is \Emp, or both inputs to \name{convexHull} are \Emp, the result shall be \Emp. These operations shall have ``trivial'' decorated versions, as described in \ssrf{lvl1excnonarops}. \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsubsection{Constructors}~ \Blabel{ss:lvl2bintvlconstructors} For the bare and decorated interval types there shall be a constructor. It returns a $\T$- or $\DT$-datum, respectively. \smallskip\noindent {\sf\bfseries Bare interval constructors.} A \bintvl constructor call either {\bf succeeds} or {\bf fails}. This notion is used to determine the value returned by the corresponding \dintvl constructor. \smallskip For the constructor $\name{numsToInterval}(l,u)$, the inputs $l$ and $u$ are $\btype$ datums. %\nedrm{ of supported \Nfmts, where the format of $l$ may differ from that of $u$. %For a given \bIdt $\T$: %\begin{itemize} % \item There shall be a version of \name{numsToInterval} where $l$ and $u$ are both of the same format, compatible with $\T$, see \ssrf{lvl2n-formats}. % \item If $\T$ is 754-conforming, there shall be a \Fmt version of \name{numsToInterval} that accepts $l$ and $u$ having any combination of supported \ieeefp formats of the same radix as $\T$. %\end{itemize} %Apart from these two requirements, what $(l,u)$ format combinations are provided is \LIdefd. %} %\nedrm{The constructor call succeeds if (a) the implementation determines that the call has a Level 1 value $\~x$, see \ssrf{lvl1reqdconstructors}, or (b) it cannot determine whether a Level 1 value exists, see the discussion at the start of this subclause. The conditions under which case (b) might occur shall be documented. % %In case (a)---that is, neither $l$ nor $u$ is \nan, and the exact extended-real values of $l$ and $u$ are known to satisfy $l\le u$, $l<\pinf$, $u>\ninf$---the result shall be a $\T$-interval containing $\~x$. %In case (b) the result shall be a $\T$-interval containing $l$ and $u$. % % If $\T$ is a 754-conforming type and $l$ and $u$ are of \ieeefp formats with the same radix as $\T$, the second case cannot arise, and the result shall be the $\T$-hull of $\~x$; in particular if $\~x$ is an exact $\T$-interval, the result is $\~x$. For other cases, the tightness of the result is \Idefd. % %Otherwise the call fails, and the result is Empty.} If neither $l$ nor $u$ is \nan, and $l\le u$, $l<\pinf$, $u>\ninf$, the result is \li{[$l$,$u$]}. Otherwise the call fails, and the result is \Emp. \smallskip For the constructor $\name{textToInterval}(\~s)$, the input $\~s$ is a string. \nadadd{The string of form \@[\;$l$\;,\;$u$\;]@ where $l<\pinf$ and $u>\ninf$ are optional number literals is called {\bf accuracy-relaxed} if either one of the literals is a rational number literal of form \itref{nlitrat} in \ssrf{lvl2numlit} or one of them is a decimal number literal of form \itref{nlit1} in \ssrf{lvl2numlit} and another is a hexadecimal number literal of form \itref{ch1nlithex} in \ssrf{lvl2numlit}.} \begin{itemize} \item If $\~s$ is a valid interval literal with Level 1 value $\~x$ \nadadd{and $\~s$ is not accuracy-relaxed}, the result shall be the hull of $\~x$ (the constructor succeeds). \item If $\~s$ is not a valid interval interval \nadadd{and $\~s$ is not accuracy-relaxed}, this constructor fails, and the result is \Emp. \nadadd{\item If $\~s$ is accuracy-relaxed and $l\le u$, the result may be any interval containing \li{[$l$,$u$]} (the constructor succeeds).} \nadadd{\item If $\~s$ is accuracy-relaxed and $l> u$, the result may be either any interval containing \li{[$u$,$l$]} (the constructor succeeds), or \Emp (the constructor fails).} \end{itemize} \medskip\noindent {\sf\bfseries Decorated interval constructors.} %Each \bintvl constructor shall have a corresponding decorated constructor, taking the same input(s) as the bare constructor. %The decorated constructor succeeds if and only if the \bintvl constructor succeeds. %The decorated constructor fails returning \nai if and only if the \bintvl constructor fails. % %If the \bintvl constructor $\name{numsToInterval}(l,u)$ succeeds, returning $\~y$, the decorated form returns $\name{newDec}(\~y)$, see \ssrf{lvl1excdecops}. % %If the \bintvl constructor $\name{textToInterval}(\~s)$ succeeds, returning $\~y$, the decorated form returns $\~y_{dy}$, where $dy$ is determined as follows: % \begin{itemize} % \item when $\~s$ is an interval literal with decorated value $\~x_{dx}$, then $dy$ shall equal $dx$, except in the case that $dx=\Dcom$ and overflow occurred, that is, $\~x$ is bounded and $\~y$ is unbounded. Then $dy$ shall equal $\Ddac$. % \end{itemize} Let the prefix \name{b-} or \name{d-} denote the bare or decorated version of a constructor. If $\name{b-numsToInterval}(l,u)$ or $\name{b-textToInterval}(\~s)$ succeeds with result $\~y$, then $\name{d-numsToInterval}(l,u)$ or $\name{d-textToInterval}(\~s)$, respectively, succeeds with result $\~y$ and decoration $\name{newDec}(\~y)$, see \ssrf{lvl1excdecops}. If $\~s$ is a \dintvl literal $\~{sx}\_\~{sd}$ with Level 1 value $\~x_{dx}$, see \ssrf{lvl2dintvllit}, and $\name{b-textToInterval}(\~{sx})$ succeeds with result $\~y$, then $\name{d-textToInterval}(\~s)$ succeeds with result $\~y_{dy}$, where $dy=dx$ except when $dx=\Dcom$ and overflow has occurred, that is, $\~x$ is bounded and $\~y$ is unbounded. Then $dy$ shall equal $\Ddac$. Otherwise the call fails, and the result is \nai. %\smallskip\noindent %{\sf\bfseries Decorated interval constructors.} %%For each constructor giving a result of the \bintvl type $\T$, there shall be a corresponding decorated constructor, with an optional extra final argument $d$ which is a decoration, and giving a result of the derived decorated type. Thus the bare constructor $\name{numsToInterval}(l,u)$ has the decorated forms $\name{numsToInterval}(l,u)$ and $\name{numsToInterval}(l,u,d)$; $\name{textToInterval}(\~s)$ has the decorated forms $\name{textToInterval}(\~s)$ and $\name{textToInterval}(\~s,d)$. The following cases arise. %%\begin{itemize} %% \item The bare constructor succeeds, returning $\~x$, and $d$ is not provided. Then the decorated form returns $\name{newDec}(\~x)$, see \ssrf{lvl1excdecops}. %% \item The bare constructor succeeds, returning $\~x$, and $d$ is provided. Then the decorated form returns $(\~x,d)$ if this is a permitted combination, and \nai otherwise. %% \item Otherwise the decorated form returns \nai. %%\end{itemize} %Each \bintvl constructor shall have a corresponding decorated constructor, taking the same input(s) as the bare constructor. %The decorated constructor succeeds if and only if the \bintvl constructor succeeds. %The decorated constructor fails returning \nai if and only if the \bintvl constructor fails. % %If the \bintvl constructor $\name{numsToInterval}(l,u)$ succeeds, returning $\~y$, the decorated form returns $\name{newDec}(\~y)$, see \ssrf{lvl1excdecops}. % %If the \bintvl constructor $\name{textToInterval}(\~s)$ succeeds, returning $\~y$, the decorated form returns $\~y_{dy}$, where $dy$ is determined as follows: % \begin{itemize} % %\item when $\~s$ is a valid interval literal with decorated value $\~x_{dx}$, then $dy$ shall equal $dx$, except in the case that $dx=\Dcom$ and overflow occurred, that is, $\~x$ is bounded and $\~y$ is unbounded. Then $dy$ shall equal $\Ddac$. % \item when $\~s$ is \li{[$l$,$u$]}, then $dy$ shall equal \Dcom, except if $\~y$ is unbounded because of overflow. Then $dy$ shall equal $\Ddac$. % % \item when $\~s$ is \li{[$l$,$u$]_$dx$}, then $dy$ shall equal $dx$, % except in the case that $dx=\Dcom$ and $\~y$ is unbounded because of overflow. Then $dy$ shall equal $\Ddac$. % % \end{itemize} % \smallskip\noindent {\sf\bfseries Exception behavior.} Exception \name{UndefinedOperation} is signaled by both the bare and the decorated constructor when the input is such that the bare constructor fails. \nadadd{ Exception \name{PossiblyUndefinedOperation} is signaled by both the bare and the decorated $\name{textToInterval}(\~s)$ constructor with accuracy-relaxed $\~s$ \begin{itemize} \item when $l> u$ and interval constructor succeeds; \item when $l\le u$ and the result is wider than the hull of \li{[$l$,$u$]}; \item optionally when $l\le u$ and the result is the hull of \li{[$l$,$u$]}. \end{itemize}} \note{When signaled by the decorated constructor it will normally be ignored since returning \nai gives sufficient information.} \nadadd{ \note{If the $\name{textToInterval}(\~s)$ constructor doesn't signal exception then $\~s$ is a valid interval literal and the result is the hull of Level 1 value of $\~s$.} \note{The behavior of the $\name{textToInterval}(\~s)$ constructor is implementation-dependent when $\~s$ is accuracy-relaxed. The least accurate implementation simply returns \Ent and signals \name{PossiblyUndefinedOperation}. The most accurate implementation fails with \name{UndefinedOperation} exception when $l>u$ and returns the hull of \li{[$l$,$u$]} without exception otherwise.}} \medskip %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsubsection{Numeric functions of intervals}~ \Blabel{ss:lvl2reqdnumintvlfns} %An implementation shall provide a $\T$-version of each numeric function in \tbref{lvl1reqdintvl2numfuns} of \ssrf{lvl1reqdnumintvlfns} for each supported \bIdt $\T$, giving a result in a supported \Nfmt $\F$ that should be compatible with $\T$, see \ssrf{lvl2n-formats}. An implementation may provide several versions, returning results in different formats. %If $\T$ is a 754-conforming type, versions shall be provided giving a result in any supported \ieeefp format of the same radix as $\T$. An implementation shall provide a $\T$-version of each numeric function in \tbref{lvl1reqdintvl2numfuns} of \ssrf{lvl1reqdnumintvlfns} giving a result in \@b64@. The mapping of a Level 1 value to a $\@b64@$ number is defined in terms of the following rounding methods: \begin{enumerate}[] \item {\em Round toward positive}: $x$ maps to the smallest $\@b64@$ number not less than $x$; $0$ maps to $\pzer$. \item {\em Round toward negative}: $x$ maps to the largest $\@b64@$ number not greater than $x$; $0$ maps to $\nzer$. \item {\em Round to nearest}: $x$ maps to the $\@b64@$ number (possibly $\pm\infty$) closest to $x$ as defined by IEEE 754-2008; \\$0$ maps to $\pzer$. \end{enumerate} \note{These functions help define operations of the standard but are not themselves operations of the standard.} A Level 1 value of $0$ shall be returned as $\nzer$ by \name{inf}, and $\pzer$ by all other functions in this subclause. \begin{enumerate}[] \setlength{\itemsep}{1ex} \item $\name{inf}(\~x)$ returns the Level 1 value rounded toward negative. \item $\name{sup}(\~x)$ returns the Level 1 value rounded toward positive. \item $\name{mid}(\~x)$: the result is defined by the following cases, where $\ul{x},\ol{x}$ are the exact (Level 1) lower and upper bounds of $\~x$: \[\begin{tabular}{l|p{.6\TW}} $\~x=\Emp$ & \nan \\ $\~x=\Ent$ & $0$ \\ $\ux=\ninf$, $\ox$ finite & the finite negative \@b64@ number of largest magnitude \\ $\ux$ finite, $\ox=\pinf$ & the finite positive \@b64@ number of largest magnitude \\ $\ux,\; \ox$ both finite & the Level 1 value rounded to nearest \end{tabular}\] The implementation shall document how it handles the last case. \item $\name{rad}(\~x)$ returns \nan if $\~x$ is empty, and otherwise the smallest \@b64@ number $r$ such that $\~x$ is contained in the exact interval $[m-r,m+r]$, where $m$ is the value returned by $\name{mid}(\~x)$. % \note{\nedrm{$\name{rad}(\~x)$ may be $\pinf$ even though $\~x$ is bounded, if $\F$ has insufficient range. However, if $\F$ is a \ieeefp format and $\T$ is the derived inf-sup type, }$\name{rad}(\~x)$ is finite for all bounded nonempty intervals.} \item $\name{wid}(\~x)$ returns \nan if $\~x$ is empty. Otherwise it returns the Level 1 value rounded toward positive. \item $\name{mag}(\~x)$ returns \nan if $\~x$ is empty. Otherwise it returns the Level 1 value rounded toward positive. \item $\name{mig}(\~x)$ returns \nan if $\~x$ is empty. Otherwise it returns the Level 1 value rounded toward negative, except that $0$ maps to $\pzer$. \end{enumerate} Each \bintvl operation in this subclause shall have a decorated version, where each input of \bintvl type is replaced by one of the corresponding \dintvl type, and the result format is that of the bare operation. Following \ssrf{lvl1excnonarops}, if any input is \nai, the result is \nan. Otherwise the result is obtained by discarding the decoration and applying the corresponding \bintvl operation. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \mysubsubsection{Boolean functions of intervals} \Blabel{ss:lvl2reqdboolintvlfns}~ % {An implementation shall provide the functions \begin{itemize} \item $\name{isEmpty}(\~x)$ and $\name{isEntire}(\~x)$ in \ssrf{lvl1reqdboolintvlfns}, \item the functions implementing the comparison relations in \tbref{lvl1reqdcompar} of \ssrf{lvl1reqdboolintvlfns}, and \item the function $\name{isNaI}(\~x)$ for input $\~x$ of any decorated type, which returns \@true@ if $\~x$ is \nai, else \@false@. \end{itemize} } Each \bintvl operation in this subclause shall have a decorated version. Following \ssrf{lvl1excnonarops}, if any input is \nai, the result is \@false@ (in particular $\name{equal}(\nai,\nai)$ is \@false@). Otherwise the result is obtained by discarding the decoration and applying the corresponding \bintvl operation. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \medskip \subsubsection{Operations on/with decorations}~ \Blabel{ss:lvl2excbaredecops} % An implementation shall provide the operations of \ssrf{lvl1excdecops}. These comprise the comparison operations $=$, $\ne$, $>$, $<$, $\ge$, $\le$ for decorations; and, for the decorated type, the operations \name{newDec}, \name{intervalPart}, \name{decorationPart} and \name{setDec}. A call $\name{intervalPart}(\nai)$, whose value is undefined at Level 1, shall return \Emp at Level 2, and shall signal the \name{IntvlPartOfNaI} exception to indicate that a valid interval has been created from the ill-formed interval.