\documentclass[nocolor,memo]{j3}
\renewcommand{\hdate}{9 November 2005}
\renewcommand{\vers}{J3/05-264r2}
\usepackage{alltt}
\usepackage[fleqn]{amsmath}
\usepackage{lineno}
\usepackage{longtable}
\usepackage{xr}
\externaldocument{007}
\input pdftest
\begin{document}
\vspace{-10pt}
\begin{tabbing}
Subject: \hspace*{0.25in}\=Intrinsic math functions\\
From: \>Van Snyder\\
Reference: \>05-248r3\\
\end{tabbing}
\pagewiselinenumbers
\leftlinenumbers
\linenumbers*
\section{Introduction}
As specified in 05-248r3, the HYPOT function a is nearly useless, and
ERFC is suboptimal.
\subsection{HYPOT}
The HYPOT function specified in 05-248r3 is nearly useless, since (1)
it's identical to CABS, and (2) the interesting function in any case is
the one that computes the $L_2$ norm of a vector of any length, not just
length 2. Instead of HYPOT we ought to add the NRM2 functions from the
BLAS, with the generic name TBD. Once one has CABS (or indeed NRM2) one
needs only a statement function to have a HYPOT spelling. Presumably, if
the length is given by an initialization expression, and happens to be
two, a decent processor will optimize NRM2 just as well as it would HYPOT
--- or maybe it won't if HYPOT isn't in the SPEC benchmark. Either HYPOT
or NRM2 can be done with SQRT(DOT\_PRODUCT(A,A)), but a carefully-done
$L_2$ norm function (e.g., the one in the BLAS) will not experience an
overflow in the calculation of an intermediate result unless the final
result overflows.
{\bf Proposal:} Add a function that computes the $L_2$ norm of an array.
\subsection{ERFC}
The ERFC function specified in 05-248r3 is not the most useful
specification for that functionality. ERFC is asymptotic to
$\exp(-x^2)/(x \sqrt\pi)$, and as such underflows for $x > \approx 9$ in
IEEE single precision. The expression $\exp(x^2) \text{erfc}(x)$, which
doesn't underflow until $x > \text{HUGE}(x)/\sqrt\pi$, appears more
frequently in statistical calculations. Real math function libraries (as
opposed to libm) frequently include a ``scaled erfc'' function,
frequently called ERFCE, that computes $\exp(x^2) \text{erfc}(x)$. Where
carefully done, implementations of this function do not experience
overflow of intermediate or final results for any positive X, and
intermediate or final results underflow only for $x >
\text{HUGE}(x)/\sqrt\pi$. It \emph{is not} computed by computing
erfc$(x)$ and multiplying by $\exp(x^2)$, as a naive user might be
tempted to do --- especially if all we provide is the functionality
presently specified in 05-248r3. $\exp(x^2)$ would overflow for $x >
\approx 9$ in IEEE single precision, and erfc$(x)$ would underflow around
the same value, so multiplying the results of those functions would
produce nonsense for $x > \approx 9$.
{\bf Proposal:} Add a function that computes an exponentially scaled
complementary error function.
\section{Syntax}
No new syntax and no changes to existing syntax.
\edits{04-007}
%=========================================================================
\subsection{Exponentially scaled complementary error function}
\sep\mgpar{294:30+}[Insert into list of Mathematical functions in
13.5.2:]
\begin{insum}
\item[ERFC\_SCALED ( X )] Exponentially-scaled complementary
error function
\end{insum}
\sep\mgpar{315:24+}[Insert after 13.7.5 EPSILON~(X):]
{\secfont\large 13.7.5$\frac12$ ERFC\_SCALED ( X )}
\desc{Exponentially-scaled complementary error function.}
\class{Elemental function.}
\argument{X shall be of type real.}
\reschar{Same as X.}
\resvalue{The value of the result is a processor-dependent approximation
to the ex\-pon\-entially-scaled complementary error function, $\exp(x^2)
\frac2{\sqrt\pi} \int_x^\infty \exp(-t^2) \text{d}t$.}
\example{The value of ERFC\_SCALED(20.0) is 0.02817434874 (approximately)}
\begin{xnote}{13.8$\frac12$}
The complementary error function is asymptotic to $\exp(-x^2)/(x
\sqrt\pi)$. As such it underflows for $x > \approx 9$ when using
single-precision IEEE arithmetic. The exponentially-scaled complementary
error function is asymptotic to $1/(x \sqrt\pi)$. As such it does not
underflow until $x > \text{HUGE}(x)/\sqrt\pi$.
\end{xnote}
%=========================================================================
\subsection{$L_2$ Norm}
\sep\mgpar{297:7+}[Insert into list of Array reduction functions in
13.5.12:]
\begin{insum}
\item[{NORM2 (X) }] $L_2$ norm of an array
\end{insum}
\sep\mgpar{340:26+}[Insert after 13.7.87 NOT~(I):]
{\secfont\large 13.7.87$\frac12$ NORM2~(X)}
\desc{$L_2$ norm of an array.}
\class{Transformational function.}
\argument{X shall be of type real. It shall not be a scalar.}
\reschar{Scalar of the same type and kind type parameter value as X.}
\resvalue{The result has a value equal to a processor-dependent
approximation to the $L_2$ norm of X if X is a rank-one array, the
Frobenius norm of X if X is a rank-two array, and the generalized $L_2$
norm of X for higher-rank arrays. In all cases, this is the square root
of the sum of the squares of all elements.}
\begin{incase}
\item X is a rank-one array.
\begin{equation*}
\text{NORM2}(X) = \sqrt{\sum_{i=1}^{\text{SIZE}(X)} X(i)^2}
\end{equation*}
\item X is a rank-two array.
\begin{equation*}
\text{NORM2}(X) = \sqrt{\sum_{i=1}^{\text{SIZE}(X,1)}
\sum_{j=1}^{\text{SIZE}(X,2)} X(i,j)^2}
\end{equation*}
\item[n] X is a rank-$n$ array.
\begin{equation*}
\text{NORM2}(X) = \sqrt{\sum_{i_1=1}^{\text{SIZE}(X,1)} \dots
\sum_{i_n=1}^{\text{SIZE}(X,n)} X(i_1, \dots,
i_n)^2}
\end{equation*}
\end{incase}
\example{The value of NORM2( (/ 3.0, 4.0 /) ) is 5.0 (approximately).}
\begin{xnote}{13.16$\frac12$}
It is recommended that the processor compute NORM2 in such a way that
intermediate results do not overflow or underflow unless the final result
would overflow or underflow, respectively.
\end{xnote}
\label{lastpage}
\end{document}