Interval arithmetic operations (source code)

= Interval arithmetic operations
{title2=$X+Y,\quad X-Y,\quad XY,\quad X/Y$}

For <closed intervals> $X=[a,b]$ and $Y=[c,d]$, exact <addition>, <subtraction> and <multiplication> give
$$
\begin{aligned}
X+Y&=[a+c,b+d],\\
X-Y&=[a-d,b-c],\\
XY&=[\min\{ac,ad,bc,bd\},\max\{ac,ad,bc,bd\}].
\end{aligned}
$$
These <interval arithmetic operations> describe all results $u\mathbin{\circ}v$ for $(u,v)$ in the <Cartesian product> $X\times Y$: the two inputs are allowed to vary independently. Independence here means freedom to choose either input anywhere in its <closed interval>; it does not assert anything about <probability>. For example, $[1,2]+[3,5]=[4,7]$ and $[1,2]-[3,5]=[-4,-1]$.

All four endpoint <products> matter when signs change. For $X=[-2,3]$ and $Y=[-4,1]$, the endpoint <products> are $8,-2,-12,3$, so $XY=[-12,8]$. Taking just $ac$ and $bd$, even after sorting them, would give $[3,8]$ and lose valid negative <products>.

For <division>, if $0\notin Y$, the <multiplicative inverse> gives $1/Y=[1/d,1/c]$ and $X/Y=X(1/Y)$. Thus $[1,2]/[3,4]=[1/4,2/3]$. This ordinary finite-<closed interval> rule requires a <denominator> that excludes zero. When the <denominator> contains zero, <division> is undefined for some pairs and can become unbounded near zero; these formulas cannot supply a finite <interval enclosure> of all quotients. The operations above use exact endpoints; a computer implementation must also apply <outward rounding>.