summaryrefslogtreecommitdiff
path: root/systems/doc/metapost/source-manual/mpman-app-numbersystems.tex
diff options
context:
space:
mode:
Diffstat (limited to 'systems/doc/metapost/source-manual/mpman-app-numbersystems.tex')
-rw-r--r--systems/doc/metapost/source-manual/mpman-app-numbersystems.tex26
1 files changed, 23 insertions, 3 deletions
diff --git a/systems/doc/metapost/source-manual/mpman-app-numbersystems.tex b/systems/doc/metapost/source-manual/mpman-app-numbersystems.tex
index 0e9dfaf09e..7e82e29c87 100644
--- a/systems/doc/metapost/source-manual/mpman-app-numbersystems.tex
+++ b/systems/doc/metapost/source-manual/mpman-app-numbersystems.tex
@@ -1,10 +1,10 @@
\svnInfo $Id$
-\section{High-precision arithmetic with MetaPost}
+\section{High-precision and interval arithmetic with MetaPost}
\label{hparith}
In addition to the fixed-point arithmetics inherited from \MF, MetaPost
can also do higher-precision arithmetics. In total, MetaPost can handle
-numeric quantities in four internal representation formats or number
+numeric quantities in five internal representation formats or number
systems. Number systems differ in rounding errors\index{rounding error}
introduced by and the speed of arithmetic operations. Simply storing a
numeric value in a variable may already introduce a rounding error, so
@@ -14,7 +14,7 @@ The internal representation format used for numeric quantities can be
determined by a command-line switch
\texttt{-numbersystem}\index{command-line!mpost?\texttt{mpost}!-numbersystem?\texttt{-numbersystem}}
when invoking the MetaPost executable. Argument is a string and can be
-one of \texttt{scaled}, \texttt{double}, \texttt{binary}, or
+one of \texttt{scaled}, \texttt{double}, \texttt{binary}, \texttt{interval} or
\texttt{decimal}. The argument is stored in an internal string variable
\texttt{numbersystem}\index{numbersystem?\texttt{numbersystem}}\label{Dnumbersystem}.
Assigning a value to this variable at run-time triggers an error.
@@ -58,6 +58,26 @@ is an integer in the range $[-9,999,999; +9,999,999]$. All arithmetic
operations are done in software using the MPFR library~\cite{lib:mpfr}
and are usually orders of magnitude slower than in \texttt{double} mode.
+The \index{interval?interval number system}\texttt{interval} number
+system MPFI~\cite{lib:mpfi}, introduced in version \texttt{2.10}, is built on the top of the MPFR library
+and an interval quantity \texttt{[}\textit{number}\texttt{,}\textit{number}\texttt{]} is entered as
+\begin{center}\index{interval\_set?\texttt{interval\_set}}\label{Dintervalset}\texttt{w := interval\_set(}\textit{number}\texttt{,}\textit{number}\texttt{);}\end{center}
+An interval is a set, the left extrema being
+\begin{center}\index{interval\_get\_left\_endpoint?\texttt{interval\_get\_left\_endpoint}}\label{Dintervalleft}\texttt{l := interval\_get\_left\_endpoint(}\textit{interval}\texttt{);}\end{center}
+and the right extrema
+\begin{center}\index{interval\_get\_right\_endpoint?\texttt{interval\_get\_right\_endpoint}}\label{Dintervalright}\texttt{r := interval\_get\_right\_endpoint(}\textit{interval}\texttt{);}\end{center}
+and it's always $l\leq r$\,; a number \texttt{x} is always seen as the interval \texttt{[x,x]}, i.e. a set with one element.
+At first glance, interval arithmetic can be confusing: if $w$ is an interval,
+$w*w$ is the set $\left\{ x*x: x\in w\right\}$, but $f(w)=w^2$ is the set $\left\{f(x): x\in w\right\} = \left\{x^2: x\in w\right\}$:
+if $w=[-1,1]$ then $w*w=[-1,1]$ and $w^2=[0,1]$. On the other hand, it's easy to verify that $w*w*w = w^3$ always. For this reason,
+given that currently the
+implementation of the MetaPost functions in MPFI mimics those of MPFR and they are not adapted to the interval arithmetic,
+the main utility of interval mode is the implementation of algorithms in MetaPost language.
+
+
+
+
+
Number system \texttt{decimal}\index{decimal?\texttt{decimal}} provides
arbitrary precision floating-point arithmetics similar to the
\texttt{binary} number system. Except that it uses a base of~10 for the