diff options
author | Karl Berry <karl@freefriends.org> | 2021-02-15 22:22:05 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-02-15 22:22:05 +0000 |
commit | 781edbbb62beb1418286c27266b5fa51f8718d88 (patch) | |
tree | d124cf1d9f555ddb87650f3bf70b4e71b946e20a /Master/texmf-dist/doc/latex/numerica/numerica-tables.tex | |
parent | e46b42c1fa31404b2a43ce352b257c1e3b00aa5f (diff) |
numerica (15feb21)
git-svn-id: svn://tug.org/texlive/trunk@57759 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/numerica/numerica-tables.tex')
-rw-r--r-- | Master/texmf-dist/doc/latex/numerica/numerica-tables.tex | 1801 |
1 files changed, 1801 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/numerica/numerica-tables.tex b/Master/texmf-dist/doc/latex/numerica/numerica-tables.tex new file mode 100644 index 00000000000..b16f90e3b7c --- /dev/null +++ b/Master/texmf-dist/doc/latex/numerica/numerica-tables.tex @@ -0,0 +1,1801 @@ +%% LyX 2.4.0-alpha1 created this file. For more info, see https://www.lyx.org/. +%% Do not edit unless you really know what you are doing. +\documentclass[english,tableposition=top]{report} +\usepackage{lmodern} +\renewcommand{\sfdefault}{lmss} +\renewcommand{\ttdefault}{lmtt} +\usepackage[T1]{fontenc} +\usepackage{textcomp} +\usepackage[latin9]{inputenc} +\setcounter{secnumdepth}{3} +\usepackage{color} +\definecolor{shadecolor}{rgb}{0.667969, 1, 1} +\usepackage{babel} +\usepackage{array} +\usepackage{float} +\usepackage{booktabs} +\usepackage{framed} +\usepackage{url} +\usepackage{multirow} +\usepackage{amsmath} +\usepackage[unicode=true,pdfusetitle, + bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=2, + breaklinks=false,pdfborder={0 0 1},backref=section,colorlinks=true] + {hyperref} + +\makeatletter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands. +%% Because html converters don't know tabularnewline +\providecommand{\tabularnewline}{\\} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands. +\newenvironment{centred}% + {\begin{center}\baselineskip=13pt\parskip=1pt}{\end{center}} +\newenvironment{lyxcode} + {\par\begin{list}{}{ + \setlength{\rightmargin}{\leftmargin} + \setlength{\listparindent}{0pt}% needed for AMS classes + \raggedright + \setlength{\itemsep}{0pt} + \setlength{\parsep}{0pt} + \normalfont\ttfamily}% + \item[]} + {\end{list}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands. +\usepackage[tables]{numerica} + +\newcommand\rel{\,\varrho\;} +\DeclareMathOperator{\erf}{erf} +\DeclareMathOperator{\gd}{gd} + +\reuse + +\usepackage{upquote} + +\makeatother + +\begin{document} +\title{\texttt{numerica-tables}~\\ +} +\author{Andrew Parsloe\\ +(\url{ajparsloe@gmail.com})} +\maketitle +\begin{abstract} +In this module of the \verb`numerica` package a command is defined +which enables the creation of multi-column tables of function values +in a wide variety of table styles. \\ +\\ +\noindent\begin{minipage}[t]{1\columnwidth}% +\begin{shaded}% + +\paragraph*{Note:} +\begin{itemize} +\item {\normalsize This document applies to version 1.0.0 of }{\normalsize\texttt{numerica-tables.def}}{\normalsize .}{\small\par} +\item {\normalsize Reasonably recent versions of the \LaTeX 3 bundles }{\normalsize\texttt{l3kernel}}{\normalsize{} +and }{\normalsize\texttt{l3packages}}{\normalsize{} are required.}{\small\par} +\item {\normalsize The }{\normalsize\texttt{booktabs}}{\normalsize{} package +is required.}{\small\par} +\item {\normalsize I refer many times in this document to }{\normalsize\emph{Handbook +of Mathematical Functions}}{\normalsize , edited by Milton Abramowitz +and Irene A. Segun, Dover, 1965. This is abbreviated to }{\normalsize\emph{HMF}}{\normalsize , +often followed by a reference to a specific table like Table 1.2.}{\small\par} +\end{itemize} +\end{shaded}% +\end{minipage} + +\tableofcontents{} +\end{abstract} + +\chapter{Introduction} + +Calling \texttt{numerica} with the \texttt{tables} package option +in the preamble, +\begin{lyxcode} +~\textbackslash usepackage{[}tables{]}\{numerica\} +\end{lyxcode} +\noindent gives access to a command \verb`\nmcTabulate` for creating +tables of function values. This command is defined in the package +\texttt{numerica-tables.def} which is loaded with \texttt{numerica.sty} +when the \texttt{tables} option is used. Note that \verb`\nmcTabulate` +uses the \texttt{booktabs} package for the construction of its tables. +The \texttt{booktabs} package is loaded automatically (provided it +is available in your \TeX{} system) when \texttt{numerica} is loaded +with the \texttt{tables} option. + +\section{Shared syntax} + +The \verb`\nmcTabulate` command (short-name form \verb`\tabulate`) +shares the syntax of \verb`\nmcEvaluate` (see \texttt{numerica-basics.pdf}) +and of \verb`\nmcIterate`, \verb`\nmcSolve` and \verb`\nmcRecur` +(see \texttt{numerica-plus.pdf}). When all options are used the command +looks like +\begin{lyxcode} +\noindent \textbackslash nmcTabulate{*}{[}settings{]}\{expr.\}{[}vv-list{]}{[}num.~format{]} +\end{lyxcode} +\begin{enumerate} +\item \verb`*` optional switch; if present ensures a single number output +with no formatting or an appropriate error message if the single number +cannot be produced; +\item \verb`[settings]` comma-separated list of \emph{key=value }settings; +\item \verb`{expr.}` mandatory argument specifying the mathematical expression +in \LaTeX{} form to be tabulated; +\item \verb`[vv-list]` comma-separated list of \emph{variable=value }items; +\item \verb`[num. format]` optional format specification for presentation +of the numerical result (rounding, padding with zeros, scientific +notation) +\end{enumerate} +Unlike \verb`\nmcEvaluate` and the other commands, for \verb`\nmcTabulate` +\begin{itemize} +\item it makes no difference to the display of the result whether the command +wraps around math delimiters, is wrapped within math delimters, or +if there are no math delimiters involved whatever; +\item the two apparently optional arguments straddling the main argument +(\verb`settings` and \verb`vv-list`) are \emph{essential}; although +neither is mandatory in the \LaTeX{} sense, each contains items necessary +for the construction of any table of function values. +\end{itemize} + +\subsection{Inherited settings} + +\label{subsec:Inherited-settings} +\begin{table} +\noindent \centering{}\caption{\protect\label{tab:introSettingsInherited}Settings options inherited +from \texttt{\textbackslash nmcEvaluate}} +\noindent \begin{center} +\begin{tabular}{ll>{\raggedright}p{4cm}>{\raggedright}p{4cm}} +\toprule +{\small key} & {\small type} & {\small meaning} & {\small default}\tabularnewline +\midrule +{\small\texttt{dbg}} & {\small int} & {\small debug `magic' integer} & {\small\texttt{0}}\tabularnewline +{\small\texttt{\textasciicircum}} & {\small char} & {\small exponent mark for sci. notation input} & {\small\texttt{e}}\tabularnewline +{\small\texttt{xx}} & {\small int (}{\small\texttt{0}}{\small /}{\small\texttt{1}}{\small )} & {\small multi-token variable switch} & {\small\texttt{1}}\tabularnewline +{\small\texttt{()}} & {\small int (}{\small\texttt{0}}{\small /}{\small\texttt{1}}{\small /}{\small\texttt{2}}{\small )} & {\small trig. function arg. parsing} & {\small\texttt{0}}\tabularnewline +{\small\texttt{o}} & & {\small degree switch for trig. functions} & \tabularnewline +{\small\texttt{log}} & {\small num} & {\small base of logarithms for }{\small{\small\verb`\log`}} & {\small\texttt{10}}\tabularnewline +{\small\texttt{vvmode}} & {\small int (0/1)} & {\small vv-list calculation mode} & {\small\texttt{0}}\tabularnewline +{\small\texttt{vvd}} & {\small tokens} & {\small vv-list display-style spec.} & {\small\texttt{\{,\}\textbackslash mskip 12mu plus 6mu minus 9mu(vv)}}\tabularnewline +{\small\texttt{vvi}} & {\small tokens} & {\small vv-list text-style spec.} & {\small\texttt{\{,\}\textbackslash mskip 36mu minus 24mu(vv)}}\tabularnewline +{*} & & {\small suppress equation numbering if }{\small\texttt{\textbackslash\textbackslash}}{\small{} +in }{\small\texttt{vvd}} & \tabularnewline +{\small\texttt{S+}} & {\small int} & {\small extra rounding for stopping criterion for sums} & {\small\texttt{2}}\tabularnewline +{\small\texttt{S?}} & {\small$\text{int}\ge0$} & {\small stopping criterion query terms for sums} & {\small\texttt{0}}\tabularnewline +{\small\texttt{P+}} & {\small int} & {\small extra rounding for stopping criterion for products} & {\small\texttt{2}}\tabularnewline +{\small\texttt{P?}} & {\small$\text{int}\ge0$} & {\small stopping criterion query terms for products} & {\small\texttt{0}}\tabularnewline +\bottomrule +\end{tabular} +\par\end{center} +\end{table} +To create a table we need to specify a function to tabulate \textendash{} +this fills the main (mandatory) argument. We also need to decide how +the function values are to be displayed \textendash{} to how many +decimal places and whether padded with zeros. These matters are determined +by what is entered in the trailing optional argument, just as with +\verb`\eval`, \verb`\iter`, \verb`\solve` and \verb`\recur`, although +there are some addtional complications peculiar to tables which are +more appropriately treated in the next chapter. + +Many of the settings available to the \verb`\eval` command are also +available to \verb`\nmcTabulate`. To save switching between documents +I reproduce the table of options found in \texttt{numerica-basics.pdf} +(with only the punctuation \texttt{p} setting missing), although for +discussion of the options you will need to refer to that document. +But note that the \texttt{dbg} key is of limited usefulness for tables: +\texttt{dbg=5} and \texttt{dbg=7} display floating point values in +their `internal' format, and for \texttt{dbg=7}, no result is displayed. + +\chapter{\texttt{\textbackslash nmcTabulate}-specific settings} + +In addition to the shared settings, \verb`\nmcTabulate` has many +settings specific to it. They are discussed in groups in subsequent +sections, some in more than one place. + +\section{Row variable settings} + +\label{sec:Row-variable-settings}Deciding on a function to tabulate +(entered in the main or mandatory argument of \verb`\nmcTablate`) +will inevitably also mean deciding on the tabulation variable (the +\emph{row} variable \verb`rvar`), and then what value to start tabulating +from (specified in the vv-list), what value to tabulate to (\verb`rstop`), +and how fine-grained the tabulation is to be, the step size (\verb`rstep`). + +\begin{table}[b] +\centering{}\caption{Row variable specification} +\begin{center} +\begin{tabular}{ll>{\raggedright}p{4cm}>{\raggedright}p{3cm}} +\toprule +{\small key} & {\small type} & {\small meaning} & {\small comment}\tabularnewline +\midrule +{\small\texttt{rvar}} & {\small token(s)} & {\small row variable} & \tabularnewline +{\small\texttt{rstep}} & {\small real num.} & {\small step size} & \tabularnewline +{\small\texttt{rstop}} & {\small real num.} & {\small stop value} & \multirow{2}{3cm}{either {\small\texttt{rstop}}{\small{} or }{\small\texttt{rows}}}\tabularnewline +{\small\texttt{rows}} & {\small int} & {\small number of rows} & \tabularnewline +{\small\texttt{rspec}} & {\small comma list} & {\small\texttt{\{start}}{\small , }{\small\texttt{step}}{\small , }{\small\texttt{stop\}}}{\small{} +or }{\small\texttt{\{start}}{\small , }{\small\texttt{step}}{\small , +}{\small\texttt{(rows)\}}} & {\small short form spec.}\tabularnewline +\bottomrule +\end{tabular} +\par\end{center} +\end{table} +The two tables in the first example below tabulate $\sin x$ and $\cos x$ +between $0$ and $1$ in increments of $0.2$. Note the start value +of the tabulation variable in the vv-list. The reason for this placement +is that for more complicated functions other parameters in the function +and therefore in the vv-list may depend on the row variable. Therefore +it is always placed in the vv-list. + +The difference in appearance of the tables results from padding with +zeros in the second (the asterisk in the trailing optional argument). +As you can see, padding applies not only to the values of the function +but also to the values of the row variable \textendash{} and makes +an obvious improvement to the table's appearance. +\begin{verbatim} + \tabulate[rvar=x,rstep=0.2,rstop=1] + { \sin x }[x=0]\qquad + \tabulate[rvar=x,rstep=0.2,rstop=1] + { \cos x }[x=0][*] +\end{verbatim} +$\Longrightarrow$ \tabulate[rvar=x,rstep=0.2,rstop=1] + { \sin x }[x=0] \qquad + \tabulate[rvar=x,rstep=0.2,rstop=1] + { \cos x }[x=0][*]\medskip{} + +Sometimes (perhaps often) it may prove more convenient to specify +the number of rows (\texttt{rows}) rather than a stop value. Only +one of \texttt{rows} and \texttt{rstop} should be given, but if both +(inadvertently) are present, it is the value of \texttt{rows} that +prevails. + +The second and third tables in the next example use an abbreviated +form of the row variable specification (\texttt{rspec}). This is a +$3$-element comma list of the form \verb`{rvar,rstep,rstop}` or +\verb`{rvar,rstep,(rows)}`. Parentheses around the third item signify +that it is \verb`rows` rather than \verb`rstop` that is being specified. +In the example below, the second table specifies \texttt{rstop} (value +\texttt{1}), the third \texttt{rows} (value \texttt{6}). + +It is worth noting that \verb`rstep` and \verb`rstop` can be \LaTeX{} +expressions \textendash{} for instance \texttt{rstop=\textbackslash sin +\textbackslash pi/2} (just as the expression for the initial value +in the vv-list can be). However \verb`rows` can only be a simple +integer expression \textendash{} an integer or integers linked by +some or all of \verb`+ - * / ( )`. +\begin{verbatim} + \tabulate[rvar=x,rstep=0.2,rows=6] + { \sin x/\cos x }[x=0][*] \qquad + \tabulate[rspec={x,0.2,1}] + { \tan x }[x=0][*] \qquad + \tabulate[rspec={x,0.2,(6)}] + { \sqrt{\sec^2 x - 1} }[x=0][*] +\end{verbatim} +$\Longrightarrow$ \tabulate[rvar=x,rstep=0.2,rows=6] + { \sin x/\cos x }[x=0][*] \qquad + \tabulate[rspec={x,0.2,1}] + { \tan x }[x=0][*] \qquad + \tabulate[rspec={x,0.2,(6)}] + { \sqrt{\sec^2 x - 1} }[x=0][*] + +\subsection{Row-variable column formatting} + +\label{subsec:Row-var-col-formatting}Various settings are available +to format the row variable column in addition to the padding option +({*}) of the trailing optional argument. +\begin{table}[H] +\centering{}\caption{Row-variable column formatting} +\begin{center} +\begin{tabular}{ll>{\raggedright}p{4cm}l} +\toprule +{\small key} & {\small type} & {\small meaning} & {\small default}\tabularnewline +\midrule +{\small\texttt{rround}} & {\small int} & {\small rounding} & {\small\texttt{1}}\tabularnewline +{\small\texttt{ralign}} & {\small char (}{\small\texttt{r/c/l}}{\small )} & {\small horizontal alignment} & {\small\texttt{r}}\tabularnewline +{\small\texttt{rfont}} & {\small chars} & {\small font (}{\small\verb`\math<chars>`}{\small )} & \tabularnewline +{\small\texttt{rhead}} & {\small tokens} & {\small header} & {\small\texttt{rvar}}\tabularnewline +{\small\texttt{rhnudge}} & int & {\small nudge header }{\small{\small\verb`<int>`}}{\small{} mu} & {\small\texttt{0}}\tabularnewline +{\small\texttt{rpos}} & {\small int (}{\small\texttt{0}}{\small\ldots}{\small\texttt{4}}{\small )} & {\small column position(s) } & {\small\texttt{1}}\tabularnewline +{\small\texttt{rvar'}} & {\small tokens} & {\small 2nd row variable col. spec. } & {\small\texttt{rvar}}\tabularnewline +{\small\texttt{rhead'}} & {\small tokens} & {\small header of 2nd rv col. (if it exists)} & {\small\texttt{rvar'}}\tabularnewline +{\small\texttt{rhnudge'}} & int & {\small nudge 2nd rv col. header }{\small{\small\verb`<int>`}}{\small{} +mu} & {\small\texttt{0}}\tabularnewline +\bottomrule +\end{tabular} +\par\end{center} +\end{table} + + +\subsubsection{Rounding: \texttt{rround}} + +After studying the previous tables, we might decide to adjust the +step size, say from $0.2$ to $0.25$. But changing \texttt{rstep} +to the new value gives a disconcerting and \emph{prima facie} false +result (the first table below). \texttt{numerica} uses a default rounding +value of $1$ for the row variable and has rounded $0.25$ down to +$0.2$ and $0.75$ up to $0.8$ accordingly. The second table corrects +matters by adjusting the row variable rounding (\texttt{rround}) to +\texttt{2}. +\begin{verbatim} + \tabulate[rvar=x,rstep=0.25,rstop=1] + { \sin x }[x=0][*]\qquad + \tabulate[rvar=x,rstep=0.25,rstop=1,rround=2] + { \sin x }[x=0][*] +\end{verbatim} +$\Longrightarrow$ \tabulate[rvar=x,rstep=0.25,rstop=1] + { \sin x }[x=0][*] \qquad + \tabulate[rvar=x,rstep=0.25,rstop=1,rround=2] + { \sin x }[x=0][*] + +\subsubsection{Alignment: \texttt{ralign}} + +By default, the alignment of all columns is to the right, as in the +previous examples. This lends itself to neat output when padding with +zeros is activated (the \verb`*` in the trailing argument) and when +some values are negative \textendash{} the minus signs can interfere +with neat output in left or centred alignments. But in a case like +the second table in the last example, you might prefer to centre the +headers for both the row and function value columns. These alignments +are independently set. For the row variable column the default alignment +is to the right \texttt{ralign=r}; \texttt{ralign=l} (lowercase L) +aligns entries in the row variable column to the left, and \texttt{ralign=c} +centres entries in the row variable column. The tables of the next +example use a \texttt{c} alignment to centre the row variable column +header. The third of those tables shows how minus signs spoil the +effect. + +\subsubsection{Font: \texttt{rfont}} + +In the second table bolding (\texttt{rfont=bf}) has been applied to +emphasize the distinction between the row variable values and the +function values. Possible values for this key are those characters +that can be adjoined to \verb`\math` to give a meaningful result. +Thus other valid values are \verb`it` (italic), \verb`sf` (sans +serif), \verb`tt` (typewriter); \verb`frak` (Fraktur); also \verb`rm` +(roman) is available, but that is the default. + +\subsubsection{Header: \texttt{rhead}} + +In the second and third tables, the header for the row variable column +has also been bolded. The default header is the row variable. That +can be replaced by giving a value to the key \texttt{rhead}. I have +used \texttt{rhead=\textbackslash boldsymbol\{x\}} (rather than \verb`\mathbf{x}`) +in order to get an italicized bold symbol. +\begin{verbatim} + \tabulate + [rvar=x,rstep=0.25,rstop=1, + rround=2,ralign=c] + { \sin x }[x=0][*]\qquad + \tabulate + [rvar=x,rstep=0.25,rstop=1,rround=2, + ralign=c,rfont=bf,rhead=\boldsymbol{x}] + { \sin x }[x=0][*] + \tabulate + [rvar=x,rstep=0.25,rstop=0.5,rround=2, + ralign=c,rfont=bf,rhead=\boldsymbol{x}] + { \sin x }[x=-0.5][*] +\end{verbatim} +$\Longrightarrow$ \tabulate + [rvar=x,rstep=0.25,rstop=1, + rround=2,ralign=c] + { \sin x }[x=0][*]\qquad + \tabulate + [rvar=x,rstep=0.25,rstop=1, + rround=2,ralign=c,rfont=bf,rhead=\boldsymbol{x}] + { \sin x }[x=0][*]\qquad + \tabulate + [rvar=x,rstep=0.25,rstop=0.5,rround=2, + ralign=c,rfont=bf,rhead=\boldsymbol{x}] + { \sin x }[x=-0.5][*]\medskip{} + +In these tables the row variable column has been given a centred alignment. +The third table shows what goes wrong when \emph{some} values are +negative. Better then is to use padding, a right alignment (the default), +and to use a phantom in the header. The first table below does this. +The second table incorporates kerning into the header to achieve the +same effect: +\begin{verbatim} + \tabulate + [rvar=x,rstep=0.25,rstop=0.5,rround=2, + rfont=bf,rhead=\boldsymbol{x}\hphantom{0}] + { \sin x }[x=-0.5][*]\qquad + \tabulate + [rvar=x,rstep=0.25,rstop=0.5,rround=2, + rfont=bf,rhead=\boldsymbol{x}\mkern 9 mu] + { \sin x }[x=-0.5][*] +\end{verbatim} +$\Longrightarrow$ \tabulate + [rvar=x,rstep=0.25,rstop=0.5,rround=2, + rfont=bf,rhead=\boldsymbol{x}\hphantom{0}] + { \sin x }[x=-0.5][*]\qquad + \tabulate + [rvar=x,rstep=0.25,rstop=0.5,rround=2, + rfont=bf,rhead=\boldsymbol{x}\mkern 9 mu] + { \sin x }[x=-0.5][*]\medskip{} + +(To my eye, aligning the $\boldsymbol{x}$ above the first column +of digits after the decimal point gives a better result than truly +centring it in the column; compare these examples with the first two +tables of the previous example.) + +\subsubsection{Nudging~the~header: \texttt{rhnudge}} + +However, you might prefer to avoid inserting positioning commands +into the actual row variable header, obscuring its true content. You +can avoid doing this by using \texttt{numerica}'s nudge setting \texttt{rhnudge}. + +The first table below reverts to the default right alignment, avoids +any positioning commands in the row variable header, but instead nudges +it into position with the setting \texttt{rhnudge=9}. For positive +nudge values, nudging works in the opposite sense to the alignment. +The units for nudging are mu (math units, 18 to a quad), but only +a number \textendash{} generally an integer \textendash{} should be +specified; the mu is supplied by \texttt{numerica}. + +In the second table below the row variable takes single digit integer +values, while the row variable name now occupies more than one character. +With a right alignment the header would protrude out to the left. +Giving \texttt{rhnudge} a \emph{negative} value (\texttt{rhnudge=-12} +in the example) brings it back to a centred position in the row variable +column. +\begin{verbatim} + \tabulate + [rvar=x,rstep=0.25,rstop=0.5,rround=2, + rfont=bf,rhead=\boldsymbol{x},rhnudge=9] + { \sin x }[x=-0.5][4*]\qquad + \tabulate + [rvar=x_{\text{int}},rstep=1,rstop=4, + rround=0,rfont=bf,rhnudge=-12, + rhead=\boldsymbol{x_{\text{int}}}] + { \sin x_{\text{int}} }[x_{\text{int}}=0][4*] +\end{verbatim} +$\Longrightarrow$ \tabulate + [rvar=x,rstep=0.25,rstop=0.5,rround=2, + rfont=bf,rhead=\boldsymbol{x},rhnudge=9] + { \sin x }[x=-0.5][4*]\qquad + \tabulate + [rvar=x_{\text{int}},rstep=1,rstop=4, + rround=0,rfont=bf,rhnudge=-12, + rhead=\boldsymbol{x_{\text{int}}}] + { \sin x_{\text{int}} }[x_{\text{int}}=0][4*] + +\subsubsection{Position in the table: \texttt{rpos}} + +\label{subsec:Row-var-col-pos}By default, the row variable column +is the \emph{first} column of the table. Its position is determined +by the value of the key \texttt{rpos}: +\begin{itemize} +\item \texttt{rpos=0}, suppressed (no row variable column); +\item \texttt{rpos=1}, first column (the default); +\item \texttt{rpos=2}, last column; +\item \texttt{rpos=3}, first and last columns;\texttt{ } +\item \texttt{rpos=4}, first and last columns, with the values in the last +column a user-defined function of the first; see §\ref{subsec:Second-row-var-col}; +\item Any other integer acts like \texttt{rpos=1}. +\end{itemize} +An example with \texttt{rpos=3} is given shortly below, §\ref{subsec:Multiple-function-tables}. + +\subsubsection{\texttt{rvar'}, \texttt{rhead'}, \texttt{rhnudge'}} + +These settings become relevant only when \texttt{rpos=4}; see §\ref{subsec:Second-row-var-col}. + +\subsection{Multiple function tables} + +How might one tabulate multiple functions simultaneously? \emph{HMF} +has many, many examples where multiple functions (like the trigonometric +or the hyperbolic functions) are tabulated in separate columns of +the same table. + +\subsubsection{By adjoining tables} + +\label{subsec:Adjoining-tables} With the settings described so far, +one way is to adjoin single column tables. In the tables below, which +display as a single multi-columned table, I have used three different +\texttt{rpos} settings (\texttt{rpos=1} is implicit in the first). +This is one way to build a table that displays as multi-column. If +you use this method, note that the \texttt{\%} comment characters +are essential at the end of the last argument of the \verb`\tabulate` +commands if you want the tables to abut exactly. Omitting them results +in a space between the tables. +\begin{verbatim} + \tabulate + [rspec={x,0.2,(6)},rhnudge=9] + { \sin x }[x=0][*]% + \tabulate + [rpos=0,rspec={x,0.2,(6)},rround=2] + { \cos x }[x=0][*]% + \tabulate + [rpos=2,rspec={x,0.2,(6)},rhnudge=9] + { \tan x }[x=0][*] +\end{verbatim} +$\Longrightarrow$ \tabulate + [rspec={x,0.2,(6)},rhnudge=9] + { \sin x }[x=0][*]% + \tabulate + [rpos=0,rspec={x,0.2,(6)},rround=2] + { \cos x }[x=0][*]% + \tabulate + [rpos=2,rspec={x,0.2,(6)},rhnudge=9] + { \tan x }[x=0][*] + +\subsubsection{Multiple functions in a single table} + +\label{subsec:Multiple-function-tables}However, tabulating more than +one function at a time is too common a need to have to resort to adjoining +tables. Instead, it suffices to enter the functions in the main argument +separated by commas. The critical thing to do is to \emph{precede +the first function with a comma}. That initial comma is the signal +\texttt{numerica} needs to make the internal adjustments for a multi-function +table (and note the \verb`o` setting, to indicate the arguments of +$\sin$ and $\cos$ are in degrees): +\begin{verbatim} + \tabulate[o,rpos=3.rvar=\theta,rstep=10,rstop=90, + rround=0,rules=ThB] + { ,\sin \theta,\cos \theta }[\theta=0][*] +\end{verbatim} +$\Longrightarrow$ \tabulate[o,rpos=3,rvar=\theta,rstep=10,rstop=90, + rround=0,rules=ThB] + { ,\sin \theta,\cos \theta }[\theta=0][*]\medskip{} + +This table also suggests a space saving possibility: since $\sin$ +and $\cos$ are complementary functions ($\cos\theta=\sin(90-\theta)$), +the values in the bottom half of the table duplicate values in the +top half, only with the columns reversed. This is the reason for the +space saving \texttt{rpos=4} setting (§\ref{subsec:Second-row-var-col}) +which enables complementary functions to be tabulated in `half tables'; +see \emph{HMF} Tables 4.10\textendash 4.12 for the trigonometric functions. + +\section{Column variable settings} + +\label{sec:Column-variable-settings}When a function of \emph{two} +variables is being tabulated, we generally think of one variable as +the primary variable and the other as a parameter. To tabulate such +a function, one way to proceed, would be to create and adjoin separate +tables, one per parameter value. But this is clumsy. A more systematic +procedure is to specify, in addition to the row variable, a \emph{column} +variable and its start, step and stop values. + +\begin{table}[b] +\caption{Column variable specification} + +\centering{}\begin{center} +\begin{tabular}{ll>{\raggedright}p{4cm}l} +\toprule +{\small key} & {\small type} & {\small meaning} & {\small default}\tabularnewline +\midrule +{\small\texttt{cvar}} & {\small token(s)} & {\small column variable} & \tabularnewline +{\small\texttt{cstep}} & {\small real num.} & {\small step size} & \tabularnewline +{\small\texttt{cstop}} & {\small real num.} & {\small stop value} & {\small either }{\small\texttt{cstop}}\tabularnewline +{\small\texttt{cols}} & {\small int} & {\small number of columns} & {\small or }{\small\texttt{cols}}\tabularnewline +{\small\texttt{cspec}} & {\small comma list} & {\small\texttt{\{cvar,cstep}}{\small , }{\small\texttt{cstop\}}}{\small{} +or}{\small\texttt{ \{cvar,cstep}}{\small ,}{\small\texttt{(cols)\}}} & {\small short form spec.}\tabularnewline +\bottomrule +\end{tabular} +\par\end{center} +\end{table} +In the following example \verb`cvar=k` is the column variable. I +have chosen a step size (\texttt{cstep}) of \texttt{2} and a stop +value (\texttt{cstop}) of \texttt{9}. As with the row variable, the +start value (\texttt{k=3}) of the column variable is specified in +the vv-list. Although in the example these values are numbers, all +three values could be \LaTeX{} expressions that evaluate to numbers. +Note also the setting for \texttt{rhead} which shows the reader of +the table that the numerical values displayed in the column headers +are values of \verb`k`. This usage occurs throughout \emph{HMF}. +\begin{verbatim} + \tabulate + [rspec={x,0.2,(6)},rround=2, + rhead=x\backslash k, + cvar=k,cstep=2,cstop=9] + { \sin kx }[k=3,x=0][*] +\end{verbatim} +$\Longrightarrow$ \tabulate + [rspec={x,0.2,(6)},rround=2,rhead=x\backslash k, + cvar=k,cstep=2,cstop=9] + { \sin kx }[k=3,x=0][*] \medskip{} + +Again, as with the row variable, rather than using an explicit stop +value (\texttt{cstop}), you might prefer to specify the number of +columns (\texttt{cols}) explicitly. I could have replaced \texttt{cstop=9} +with \texttt{cols=4} to get the same result. Note that the number +of columns specified here is the number of \emph{function value} columns; +the row variable column is ignored for this count. + +And again, as with the row variable, it is possible to condense the +specification into a comma list (\texttt{cspec}). This is a $3$-element +comma list of the form \verb`{cvar,cstep,cstop}` or \verb`{cvar,cstep,(cols)}` +where the parentheses distinguish \texttt{cols} from \texttt{cstop} +in the third item. Thus, for the preceding table I could have written +\begin{verbatim} + \tabulate + [rspec={x,0.2,(6)},rround=2,rhead=x\backslash k, + cvar=k,cstep=2,cols=4] + { \sin kx }[k=3,x=0][*] +\end{verbatim} +or +\begin{verbatim} + \tabulate + [rspec={x,0.2,(6)},rround=2,rhead=x\backslash k, + cspec={k,2,(4)}] + { \sin kx }[k=3,x=0][*] +\end{verbatim} +or +\begin{verbatim} + \tabulate + [rspec={x,0.2,(6)},rround=2,rhead=x\backslash k, + cspec={k,2,9}] + { \sin kx }[k=3,x=0][*] +\end{verbatim} +and produced the same table. + +Although \verb`cstep` and \verb`cstop` can be \LaTeX{} expressions +\textendash{} for instance \texttt{cstop=\textbackslash pi/2} \textendash{} +\verb`cols` can only be a simple integer expression \textendash{} +an integer, or integers linked by some or all of \verb`+ - * / ( )`. + +\subsection{Column header formatting} + +\label{subsec:Column-header-formatting} +\begin{table} +\begin{centering} +\caption{Column variable header formatting} +\begin{center} +\begin{tabular}{ll>{\raggedright}p{4cm}l} +\toprule +{\small key} & {\small type} & {\small meaning} & {\small default}\tabularnewline +\midrule +{\small\texttt{chstyle}} & {\small int (0/1/2/3)} & {\small header style} & {\small\texttt{0}}\tabularnewline +{\small\texttt{ctitle}} & {\small tokens} & {\small single col. alternative header} & \tabularnewline +{\small\texttt{chead}} & {\small tokens} & {\small user-defined header} & \tabularnewline +{\small\texttt{calign}} & {\small char (r/c/l)} & {\small column alignment} & {\small\texttt{r}}\tabularnewline +{\small\texttt{chnudge}} & {\small int} & {\small nudge header }{\small{\small\verb`int`}}{\small{} mu} & {\small\texttt{0}}\tabularnewline +{\small\texttt{chround}} & {\small int} & {\small column header rounding} & {\small\texttt{0}}\tabularnewline +\bottomrule +\end{tabular} +\par\end{center} +\par\end{centering} +\end{table} +There are four built-in style settings for the header to the column +variable (or function value) columns (the `ch' prefix evoking `column +header'). If these don't meet your needs or otherwise satisfy, then +it is possible to define your own header to the function value columns +using the key \texttt{chead}. First I discuss the built-in styles. + +\subsubsection{Header style: single-column case} + +When there is only one column of function values, the function being +tabulated is by default set as the header to the column. This corresponds +to setting \texttt{ctitle={*}} (see §\ref{subsec:Title:-ctitle-setting} +below). You may want some other header. Then give \texttt{ctitle} +some other value (although note that giving it the value \texttt{{*}{*}} +will set both the function and the vv-list as the header; again see +§\ref{subsec:Title:-ctitle-setting}). Whatever value you set, it +will be typeset between math delimiters (\verb`$` signs) and can +be nudged (see §\ref{subsec:Nudgingtheheaders:-chnudge}) left or +right to fine-tune its position in the column. (If you want an asterisk +as the header, you will need to place it between two pairs of braces, +\texttt{ctitle=\{\{{*}\}\}} to prevent it being misinterpreted as +the default setting.) + +If you want some more complicated header, perhaps not constrained +by the \verb`$` delimiters, then give \texttt{chead} a value. This +key I discuss below in §\ref{subsec:chead}. \texttt{chead} is entirely +up to the user to specify, including any math environment and positioning. + +If both \texttt{ctitle} and \texttt{chead} are given, the \texttt{chead} +value prevails. + +\subsubsection{Header~style: multi-column case} + +\texttt{chstyle=0} which is the default gives a header of the form +displayed in the last example, with only the column-variable value +at the head of each column. This style generally requires the row-variable +header to indicate what the values denote, as in \texttt{rhead=x\textbackslash backslash +k} where the backslash separates row from column variable. \emph{HMF} +contains a multitude of instances; see Tables~9.7, 17.5, 21.1, 24.3, +27.4, etc. for examples. + +\texttt{chstyle=1} changes the header of the \emph{first} function +value column to the form \emph{variable=value} \textendash{} in the +example below, to $k=3$. This may be an apt choice when the columns +are narrow, perhaps from using a small rounding value. I can find +only one real instance in \emph{HMF}, Table~26.7. Note that the row +variable setting \texttt{rhead} no longer needs the `\texttt{\textbackslash backslash +k}' part since the column variable is now explicitly indicated. + +\texttt{chstyle=2} changes the header of all function value columns +to the form \emph{variable=value}.\emph{ }In \emph{HMF} examples are +Tables~7.4, 7.9, 10.10, 16.6, etc. Note that the row variable setting +\texttt{rhead} no longer needs the `\texttt{\textbackslash backslash +k}' part since the column variable is now explicitly indicated (the +right-hand table). +\begin{verbatim} + \tabulate + [rspec={x,0.2,(6)},rround=2, + cspec={k,2,(2)},chstyle=1] + { \sin kx }[k=3,x=0][3*]\quad + \tabulate + [rspec={x,0.2,(6)},rround=2, + cspec={k,2,(3)},chstyle=2] + { \sin kx }[k=3,x=0][3*] +\end{verbatim} +$\Longrightarrow$ \tabulate + [rspec={x,0.2,(6)},rround=2, + cspec={k,2,(3)},chstyle=1] + { \sin kx }[k=3,x=0][3*]\quad + \tabulate + [rspec={x,0.2,(6)},rround=2, + cspec={k,2,(3)},chstyle=2] + { \sin kx }[k=3,x=0][3*]\medskip{} + +Finally, \texttt{chstyle=3} fills each column-variable header with +the expression being tabulated but with the column variable replaced +by its respective values. See \emph{HMF} Tables~5.4, 8.1, 9.1, 19.1, +etc. for examples. +\begin{verbatim} + \tabulate + [rspec={x,0.2,(6)},rround=2, + cspec={k,2,(3)},chstyle=3] + { \sin kx }[k=3,x=0][4*] +\end{verbatim} +$\Longrightarrow$ \tabulate + [rspec={x,0.2,(6)},rround=2, + cspec={k,2,(3)},chstyle=3] + { \sin kx }[k=3,x=0][4*] + +\subsubsection{User-defined header: \texttt{chead}} + +\label{subsec:chead}Perhaps none of the built-in styles appeal? By +assigning content to the key \texttt{chead}, users can create their +own header to the function value columns. \texttt{chead} must contain +the correct number of tab characters (\verb`&`), allowing for any +\verb`\multicolumn`-s used, but ignoring the row variable column +or columns. It is a header only to the function value columns. The +user will need to insert \verb`$` signs as appropriate. + +Non-empty content for the \texttt{chead} key overrides any \texttt{chstyle} +setting and in the case of a single function value column, overrides +any \texttt{ctitle} setting. + +\subsubsection{Alignment: \texttt{calign}} + +The function value columns are aligned right (\texttt{calign=r}) by +default. Also available are \texttt{calign=c} for centred alignment +and \texttt{calign=l} (lowercase L) for left alignment. Using centred +alignment with {\ttfamily\verb`chstyle=2`} in the now familiar +example table gives +\begin{verbatim} + \tabulate + [rspec={x,0.2,(6)},rround=2,ralign=c, + cspec={k,2,(3)},chstyle=2,calign=c] + { \sin kx }[k=3,x=0][*] +\end{verbatim} +$\Longrightarrow$ \tabulate + [rspec={x,0.2,(6)},rround=2,rhead=x,ralign=c, + cspec={k,2,(3)},chstyle=2,calign=c] + { \sin kx }[k=3,x=0][*]\medskip{} + +\noindent The first column of function values looks better, but the +minus signs spoil the effect in the others. Handling signs in tables +is discussed below; see §\ref{subsec:Signs}. + +\subsubsection{Nudging~the~headers: \texttt{chnudge}} + +\label{subsec:Nudgingtheheaders:-chnudge}In left or right alignment +it is possible to nudge the headers in the opposite direction by giving +a numerical value to the the key \texttt{chnudge}. The header is moved +by the specified number of mu (math units; 18 to a quad). Note that +the `mu' does not need to be written. \texttt{numerica} provides +that. In the example I have chosen \texttt{chnudge=12} to nudge the +column headers to the left to give a centred effect to the header +but leaving the function values with their (potentially) awkward minus +signs right aligned. +\begin{verbatim} + \tabulate + [rspec={x,0.2,(6)},rround=2,rhnudge=9, + cspec={k,2,(3)},chstyle=2,chnudge=12] + { \sin kx }[k=3,x=0][*] +\end{verbatim} +$\Longrightarrow$ \tabulate + [rspec={x,0.2,(6)},rround=2,rhnudge=9, + cspec={k,2,(3)},chstyle=2,chnudge=12] + { \sin kx }[k=3,x=0][*]\medskip{} + +The \texttt{chnudge} value does not need to be positive. Negative +nudges can be useful when a column header is \emph{longer} than the +rounded function values. In the second example below, I've reduced +the rounding value for function values to $3$, and chosen an initial +$k$ value of $100$ to ensure this circumstance. To centre the column +headers I have used \texttt{chnudge=-9}. +\begin{verbatim} + \tabulate + [rspec={x,0.2,(6)},rround=2,rhnudge=9, + cspec={k,2,(3)},chstyle=2,chnudge=-9] + { \sin kx }[k=100,x=0][3*] +\end{verbatim} +$\Longrightarrow$ \tabulate + [rspec={x,0.2,(6)},rround=2,rhnudge=9, + cspec={k,2,(3)},chstyle=2,chnudge=-9] + { \sin kx }[k=100,x=0][3*] + +\subsubsection{Rounding: \texttt{chround}} + +In the examples so far, the column variable has incremented in integer +steps. The default rounding value for the column variable is $0$ +(for the row variable it is $1$), so if it increments by some non-integer +amount, the result will be confusing \textendash{} if $k$ incremented +by, say, $0.25$, starting from $k=3$, then the next column would +also have a header $k=3$ (since $3.25$ with a rounding value $0$ +rounds to $3$). The appropriate key to remedy this state of affairs +is \texttt{chround}. For a step size of $0.25$ the appropriate setting +is \texttt{chround=2}. +\begin{verbatim} + \tabulate + [rspec={x,0.2,(6)},rround=2,rhnudge=9, + cspec={k,0.25,(3)},chstyle=2,chround=2] + { \sin kx }[k=3,x=0][*] +\end{verbatim} +$\Longrightarrow$ \tabulate + [rspec={x,0.2,(6)},rround=2,rhead=x,ralign=r,rhnudge=9, + cspec={k,0.25,(3)},chstyle=2,chround=2] + { \sin kx }[k=3,x=0][*] + +\section{Whole-of-table formatting} + +\label{sec:Whole-of-table-formatting}There are a number of settings +pertaining to the appearance of the table as a whole, things like +the position of the row variable column, division of the function +values into blocks to aid readability, the presence of horizontal +rules or of a collective column title or of a footer row. I discuss +these here. + +\begin{table}[H] +\noindent \centering{}\caption{\protect\label{tab:Table-formatting-settings}Table formatting} +\noindent \begin{center} +\begin{tabular}{ll>{\raggedright}p{4cm}l} +\toprule +{\small key} & {\small type} & {\small meaning} & {\small default}\tabularnewline +\midrule +{\small\texttt{ctitle}} & {\small tokens} & {\small collective title for function-value columns} & \tabularnewline +{\small\texttt{rules}} & {\small chars} & {\small horizontal rules template} & {\small\texttt{ThB}}\tabularnewline +{\small\texttt{foot}} & {\small tokens} & {\small content of footer line} & \tabularnewline +{\small\texttt{rpos}} & {\small int (}{\small\texttt{0}}{\small\ldots}{\small\texttt{4}}{\small )} & {\small row-variable column position(s)} & {\small\texttt{1}}\tabularnewline +{\small\texttt{rbloc}} & {\small comma list} & {\small division of rows into blocks} & \tabularnewline +{\small\texttt{rblocsep}} & {\small length} & {\small extra spacing between blocks of rows} & {\small\texttt{1 ex}}\tabularnewline +\bottomrule +\end{tabular} +\par\end{center} +\end{table} + + +\subsection{Title for function-value columns: \texttt{ctitle}} + +\label{subsec:Title:-ctitle-setting}The function value columns have +individual headers, formatted in the various ways provided by the +settings discussed above, but it can also be helpful to have a collective +title for these columns. This is provided by the \texttt{ctitle} key. +This can be set to whatever you like (e.g. \texttt{ctitle=\textbackslash text\{Fred\}}), +but for more relevant titles there are two in-built settings: \texttt{ctitle={*}}, +which makes the formula the title, and \texttt{ctitle={*}{*}}, which +makes a title of the formula and vv-list. In the example below, it +makes no sense to display the vv-list since it contains only the initial +values of the row and column variables, already obvious in the table; +hence \texttt{ctitle={*}}. +\begin{verbatim} + \tabulate + [rspec={x,0.25,(5)},rround=2,rhnudge=9, + cspec={k,0.25,(3)},chstyle=2,chround=2,ctitle=*] + { \sin kx }[k=3,x=0][*] +\end{verbatim} +$\Longrightarrow$ \tabulate + [rspec={x,0.25,(5)},rround=2,rhnudge=9, + cspec={k,0.25,(3)},chstyle=2,chround=2,ctitle=*] + { \sin kx }[k=3,x=0][*]\medskip{} + +For an example of \texttt{ctitle={*}{*}} see §\ref{subsec:Rules:-rules-setting}. + +\subsection{Rules: \texttt{rules} setting} + +\label{subsec:Rules:-rules-setting}The \texttt{booktabs} package +which \texttt{numerica} uses is most emphatic that one should `1. +Never, ever use vertical rules. 2. Never use double rules.' Most +of the tables proper in \emph{HMF} lack rules of any kind although +closer inspection shows smaller tables within the text generally \emph{are} +delimited by horizontal rules (often also with vertical rules).\footnote{The tables in \emph{HMF} are often inelegantly typeset, and sometimes +ugly. For all that, I have used it as a source of table types, of +the variety of structures that the editors found necessary or at least +useful for presenting a multitude of different kinds of numerical +data.} I have used horizontal rules in the various examples in the present +document because these too are tables within text. Some form of delineation +seems necessary. Also, to my eye, the table title, $\sin kx$, in +the last example seems `naked' without a rule to emphasize its domain. + +The \texttt{rules} key enables precisely which rules are used to be +specified. The value of the key is a `word' \textendash{} a sequence +of letters \textendash{} where the characters have the significance +and default thicknesses (from \texttt{booktabs}) shown in Table~\ref{tab:Rules}. +The default setting is \texttt{rules=ThB}. To insert a rule beneath +the title, for example, change this to \texttt{rules=TthB}. If in +addition you are using a footer row and want a rule above it, then +the specification is \texttt{rules=TthfB}. + +\begin{table}[H] +\noindent \centering{}\caption{\protect\label{tab:Rules}Rules} +\noindent \begin{center} +\begin{tabular}{llll} +\toprule +{\small char} & {\small rule} & {\small position} & {\small default rule thickness}\tabularnewline +\midrule +{\small\texttt{T}} & {\small top rule} & {\small above table} & {\small\texttt{\textbackslash heavyrulewidth=.08em}}\tabularnewline +{\small\texttt{t}} & {\small title rule} & {\small below title} & {\small\texttt{\textbackslash cmidrulewidth =.03em}}\tabularnewline +{\small\texttt{h}} & {\small header rule} & {\small below header} & {\small\texttt{\textbackslash lightrulewidth=.05em}}\tabularnewline +{\small\texttt{f}} & {\small footer rule} & {\small above footer} & {\small\texttt{\textbackslash cmidrulewidth =.03em}}\tabularnewline +{\small\texttt{B}} & {\small bottom rule} & {\small below table} & {\small\texttt{\textbackslash heavyrulewidth=.08em}}\tabularnewline +\bottomrule +\end{tabular} +\par\end{center} +\end{table} +If you wish to change the thickness of a rule from its default, then +enter new values for any or all of {\small\texttt{\textbackslash heavyrulewidth}}, +{\small\texttt{\textbackslash lightrulewidth}}, {\small\texttt{\textbackslash cmidrulewidth}} +in the preamble. The values listed in Table~\ref{tab:Rules} are +the default values in the \texttt{booktabs} package (except for the +footer rule, which \texttt{booktabs} does not cover; in \texttt{numerica} +the footer rule is assigned a thickness of {\small\texttt{\textbackslash cmidrulewidth}}). + +In the example table below, a rule for the column title has been specified +(the \verb`t` in the setting \verb`rules=TthB`). Also note the use +of \texttt{ctitle={*}{*}}. The fornula contains an extra parameter +$a$, assigned a value in the vv-list. It now makes sense to display +the vv-list in the column title (but note the braces around \texttt{k} +and \texttt{x} so that they don't show in the vv-list). +\begin{verbatim} + \tabulate + [rspec={x,0.25,(5)},rround=2,rhnudge=9, + cspec={k,0.25,(3)},chstyle=2,chround=2, + ctitle=**,rules=TthB] + { a\sin kx }[a=2/\pi,{k}=3,{x}=0][*] +\end{verbatim} +$\Longrightarrow$ \tabulate + [rspec={x,0.25,(5)},rround=2,rhnudge=9, + cspec={k,0.25,(3)},chstyle=2,chround=2, + ctitle=**,rules=TthB] + { a\sin kx }[a=2/\pi,{k}=3,{x}=0][*] + +\subsection{Footer row: \texttt{foot} setting} + +Some tables have a footer row and \texttt{numerica} allows such a +row to be inserted, but its entire content, with one exception, is +the responsibility of the user, including insertion of the necessary +number of tab characters \verb`&`. This will be $1$ less than the +total number of columns (including row variable columns) in the table +\textendash{} or some adjustment thereof if you use \verb`\multicol`. +You can put into the footer what you wish. +\begin{lyxcode} +foot=<tokens> +\end{lyxcode} +\emph{HMF} uses the footer mainly for cryptic descriptions of the +accuracy and needs of interpolation methods. + +The one exception is when \texttt{foot={*}}. This will fill the footer +with the header, but \emph{reversed}. This is useful for tabulating +complementary functions like the sine and cosine or, more generally, +$f(x)$ and $g(x)$ where $g(x)=f(k-x)$ for some constant $k$. Values +for the complementary function are read from the bottom up and require +a reversed row variable column on the right of the table; see §\ref{subsec:Second-row-var-col}. + +\subsubsection{Footer functions} + +It is also possible to use the footer for displaying the values of +certain column functions. \texttt{numerica} provides five of these. +They can be used in the footer (and only in the footer): \verb`SUM`, +\verb`AVE` (average), \verb`MAX`, \verb`MIN` and \verb`DEL` (for +$\Delta$=\verb`MAX-MIN`). These functions act on the function values +of the column they are in. They \emph{do not} combine mathematically: +entering \verb`MAX-MIN` in the footer of a given column will produce +a footer entry containing two values (those of \verb`MAX` and \verb`MIN`) +separated by a minus sign, not the value of \verb`DEL`. The numerical +output from each function is automatically wrapped in math delimiters +(\verb`$`) so that minus signs display correctly. + +In the following example, I have chosen a column variable step size +of zero. This is possible because in the column spec., I have also +specified the exact number of columns. Zeroing the step size means +the same set of figures can be used for the five footer functions +to act on. +\begin{verbatim} + \tabulate + [rspec={x,0.25,(5)},rround=2,rhead=x,ralign=r,rhnudge=9, + cspec={k,0,(5)},chstyle=2, + chround=2,calign=r,ctitle=**,rules=TthfB, + foot={\small Func:} & SUM & AVE & MAX & MIN & DEL ] + { a\sin kx }[a=2/\pi,{k}=3.5,{x}=0][*] +\end{verbatim} +$\Longrightarrow$ \tabulate + [rspec={x,0.25,(5)},rround=2,rhead=x,ralign=r,rhnudge=9, + cspec={k,0,(5)},chstyle=2, + chround=2,calign=r,ctitle=**,rules=TthfB, + foot={\small Func:}&SUM&AVE&MAX&MIN&DEL] + { a\sin kx }[a=2/\pi,{k}=3.5,{x}=0][*] + +\subsection{Second row variable column} + +\label{subsec:Second-row-var-col}In §\ref{subsec:Row-var-col-pos} +I discussed \texttt{rpos=0,1,2,3}. There is another value available +for this key, \texttt{rpos=}4. Like \texttt{rpos=3} this adds the +row variable column to both left and right sides of the table, but +for the right column the values are functions of those in the left +column. + +For example, the sine and cosine are complementary functions; when +working in degrees $\cos\theta=\sin(90-\theta)$. We can exploit this +fact to halve the table size needed to tabulate the two functions. +\begin{verbatim} + \tabulate[o,rpos=4,rspec={\theta,5,45},rround=0, + chnudge=14,rvar'=90-\theta,rhead'=\theta', + rules=ThfB,foot=*] + { ,\sin\theta,\cos\theta }[\theta=0][*] +\end{verbatim} +$\Longrightarrow$ \tabulate[o,rspec={\theta,5,45},rround=0,rpos=4, + chnudge=14,rvar'=90-\theta,rhead'=\theta', + rules=ThfB,foot=*] + { ,\sin\theta,\cos\theta }[\theta=0][*]\ \medskip{} + +\noindent where $\theta'=90-\theta$. The first half of the tabulation +is read normally, down and from the left. The second half of the tabulation +is read up and from the right. Note the degree setting \verb`o` in +the settings option and +\begin{itemize} +\item the use of \verb`rvar'` to specify the values tabulated on the right +(\verb`rvar'` defaults to \verb`rvar`); +\item the use of \verb`rhead'` to specify the content of the header for +the right-hand row variable column (\verb`rhead'` defaults to \verb`rvar'`); +\item the footer setting \texttt{foot={*}} to obtain the header reversed +in the footer; +\item a rule \emph{above} the footer row specified by the \verb`f` added +to the \verb`rules` setting, \verb`rules=ThfB`. +\end{itemize} +Although there is a significant space saving with tables of this kind +(see \emph{HMF} Tables 4.10, 4.11, 4.12), they are not `kind to the +reader'. They require a certain concentration to read and in my view +should be avoided unless space is seriously constrained. + +\emph{HMF} Tables 6.1 and 6.2 are tables of the gamma function and +its relatives where $y=x-1$ is used (stemming from $y!=\Gamma(x-1)$) +in the row variable column on the right; Table 6.5 in effect uses +$\langle1/x\rangle$ (the nearest integer to $1/x$) for the row variable +on the right. + +\subsection{Separating blocks of rows: \texttt{rbloc}} + +Readability of long columns of figures can be aided by breaking the +columns into blocks with extra white space between blocks of rows. +This is achieved with the \texttt{rbloc} key: +\begin{lyxcode} +rbloc~=~<comma~list~of~positive~integers> +\end{lyxcode} +specifies how many rows belong to each block. For example, \texttt{rbloc=\{5,5,6\}} +breaks the table into blocks of $5$ rows, $5$ rows, then $6$ rows. +If the number of rows in the table is greater than the sum of the +entries in the comma list, then division into blocks continues as +specified by the last entry in the comma list. Thus \texttt{rbloc=5} +(strictly \texttt{rbloc=\{5\}} but the braces can be omitted in this +case since no comma is enclosed) divides a table into blocks of $5$ +rows; \texttt{rbloc=\{1,5\}} divides a table into $1$ row followed +by blocks of $5$ rows. A division of this kind may be appropriate +when, say, the row variable runs from $0$ to $1$ in increments of +$0.1$ \textendash{} there are $11$ rows of which the first (when +the row variable is zero) may have distinctive values. + +\noindent\begin{minipage}[t]{1\columnwidth}% +\begin{shaded}% + +\subsubsection*{The pull of the nice round number} + +However, this is not how \emph{HMF} sets out its tables.\emph{ }The +dominant practice in \emph{HMF} is division into blocks of (generally) +$5$ rows, many of which start with a zero value for the row variable. +Rather than isolate this initial value, they include it in the first +block of $5$, then continue with blocks of $5$ until a single isolated +row is left at the bottom of the page or the table. There seems to +be a psychological need to finish a page or table with the row variable +set to a nice round number. Thus: tabulate from $0$ to $10$ rather +than $0$ to $9$, from $0$ to $1$ rather than $0$ to $0.9$, and +even from $0$ to $30$ or $0$ to $2$ rather than $0$ to $29$ +or $0$ to $1.9$. Using blocks of $5$ the consequence is that there +is always an isolated line at the end \textendash{} a kind of punctuation, +marking the end of the page or the table.\end{shaded}% +\end{minipage} + +\medskip{} +In the next example I have divided the columns into blocks of $5$ +rows by means of the setting \texttt{rbloc=5}. +\begin{verbatim} + \tabulate[o,rspec={\theta,10,90},rround=0,rbloc=5] + { ,\sin \theta, \cos \theta}[\theta=0][*] +\end{verbatim} +$\Longrightarrow$ \tabulate[o,rspec={\theta,10,90},rround=0,rbloc=5] + { ,\sin \theta, \cos \theta}[\theta=0][*] + +\subsubsection{Adjusting the extra space\texttt{ rblocsep} } + +By default \texttt{numerica} sets the extra space between blocks of +rows at \verb`1 ex`. This value can easily by changed with the setting +\texttt{rblocsep=<length>}. The units need to be included in the specification. +The default is $1$ \texttt{ex.} + +\section{Function value formatting} + +\label{sec:Function-value-formatting} +\begin{table} + +\noindent \begin{centering} +\caption{\protect\label{tab:Function-value-formatting}Function value formatting} +\noindent \begin{center} +\begin{tabular}{cc>{\raggedright}p{4cm}c} +\toprule +{\small key} & {\small type} & {\small meaning} & {\small default}\tabularnewline +\midrule +{\small\texttt{(pad)}} & {\small int} & {\small (t-notation) phantom padding} & \tabularnewline +{\small\texttt{signs}} & {\small int} & {\small sign handling for function values} & {\small\texttt{0}}\tabularnewline +{\small\texttt{diffs}} & {\small int } & {\small insert differences \& pre-pad with zeros} & {\small\texttt{0}}\tabularnewline +{\small\texttt{Q?}} & {\small tokens} & {\small special cell conditional} & \tabularnewline +{\small\texttt{A!}} & {\small tokens} & {\small special cell formatting } & \tabularnewline +\bottomrule +\end{tabular} +\par\end{center} +\par\end{centering} +\end{table} +In the examples used so far, function values have been limited to +a narrow range, generally $[-1,1]$. What happens when function values +span orders of magnitude? + +\subsection{Trailing optional argument} + +The primary tool for function value formatting is the trailing optional +argument of the \verb`\tabulate` command where the rounding value +is specified, padding with zeros is set or not (generally \emph{set}), +and scientific notation is set or not. Elegant scientific notation, +set with an \texttt{x} in the trailing optional argument, is generally +not appropriate for use in tables; see the first table below. Adding +a prime to the \texttt{x} in the trailing optional argument (the second +table) so that scientific notation extends to numbers in the range +$[1,10)$ helps, particularly with the \emph{left} alignment chosen +for the function value column, but the result is wasteful of space +and the repetition of the `$\times10$' is borderline distracting +and would certainly be so for a larger table. The \texttt{x} specification +should be used in tables, if at all, only for small tables \textendash{} +a few function values at most. +\begin{verbatim} + \tabulate[rspec={x,1,3},rround=0] + { e^x}[x=-5][*x]\qquad + \tabulate[rspec={x,1,3},rround=0,calign=l] + { e^x}[x=-3][*x']\qquad +\end{verbatim} +$\Longrightarrow$ \tabulate[rspec={x,1,3},rround=0] + { e^x }[x=-3][*x]\qquad + \tabulate[rspec={x,1,3},rround=0,calign=l] + { e^x}[x=-3][*x']\qquad + +\subsubsection{The \texttt{t} option} + +\emph{HMF} uses a special notation for coping with function values +spanning orders of magnitude. This notation can be invoked by inserting +\texttt{t} in the trailing optional argument. Repeating the previous +two tables, and adding a \texttt{chnudge} value, gives a more compact +and visually appealing result: +\begin{verbatim} + \tabulate[rspec={x,1,3},rround=0,chnudge=24] + { e^x}[x=-3][*t]\qquad + \tabulate[rspec={x,1,3},rround=0,chnudge=24] + { e^x}[x=-3][*t'] +\end{verbatim} +$\Longrightarrow$ \tabulate[rspec={x,1,3},rround=0,chnudge=24] + { e^x}[x=-3][*t]\qquad + \tabulate[rspec={x,1,3},rround=0,chnudge=24] + { e^x}[x=-3][*t'] + +\subsection{Padding the exponent: \texttt{(pad)}} + +In the second table of the last example some might quibble at the +lack of alignment of the left parentheses. \emph{HMF} tends to align +these and \texttt{numerica} offers the setting +\begin{lyxcode} +(pad)~=~<integer> +\end{lyxcode} +to achieve the effect. \texttt{<integer>} is the number of digits/characters +to pad to. In the last example, the setting is \texttt{(pad)=2}. Here +it is repeated with this setting: +\begin{verbatim} + \tabulate[rspec={x,1,3},rround=0,chnudge=24,(pad)=2] + { e^x}[x=-3][*t]\qquad + \tabulate[rspec={x,1,3},rround=0,chnudge=24,(pad)=2] + { e^x}[x=-3][*t'] +\end{verbatim} +$\Longrightarrow$ \tabulate[rspec={x,1,3},rround=0,chnudge=24,(pad)=2] + { e^x}[x=-3][*t]\qquad + \tabulate[rspec={x,1,3},rround=0,chnudge=24,(pad)=2] + { e^x}[x=-3][*t']\medskip{} + +Note that this setting is relevant only when the \texttt{t} option +is used in the trailing number-formatting argument of the \verb`\tabulate` +command. Examples in \emph{HMF} of the style exemplified by the first +table are, among others, Tables 8.6, 9.2, 20.1, and of the style exemplified +by the second table, among many, Tables 9.9, 10.5, 13.1, 14.1, 19.1. + +\subsection{Accommodating signs: \texttt{signs}} + +\label{subsec:Signs}Instead of $e^{x}$ as the test function, use +$e^{x}-1.$ Now there are positive, zero and negative function values +to contend with. Recall that in the `t-notation' the \emph{exponent} +is the parenthesized integer part of a number, the \emph{significand} +the following decimal figures. \texttt{numerica} offers the \texttt{signs} +key to align (or not) the exponents. The setting is +\begin{lyxcode} +signs~=~<integer> +\end{lyxcode} +There are four effective values for \texttt{<integer>} and the do-nothing +default (\texttt{signs=0}): +\begin{itemize} +\item \texttt{signs=2 }inserts a $+$ sign between exponent and significand +of every non-negative number; +\item \texttt{signs=1 }inserts a $+$ sign between exponent and significand +of every non-negative number immediately preceding or following a +negative number; +\item \texttt{signs=-1 }inserts a $+$ sign between exponent and significand +of any non-negative number immediately preceding or following a negative +number, and a phantom $-$ sign between exponent and significand of +every other non-negative number; +\item \texttt{signs=-2 }inserts a phantom $-$ sign between exponent and +significand of every non-negative number; +\end{itemize} +With the `t-notation', the negative values and \verb`signs=2` seem +the appropriate ones to use : +\begin{verbatim} + \tabulate[rspec={x,1,3},rround=0,chnudge=9, + (pad)=2,signs=-2] + { e^x-1}[x=-3][4*t']\qquad + \tabulate[rspec={x,1,3},rround=0,chnudge=9, + (pad)=2,signs=-1] + { e^x-1}[x=-3][4*t']\qquad + \tabulate[rspec={x,1,3},rround=0,chnudge=9, + (pad)=2,signs=2] + { e^x-1}[x=-3][4*t'] +\end{verbatim} +$\Longrightarrow$ \tabulate[rspec={x,1,3},rround=0,chnudge=9, + (pad)=2,signs=-2] + { e^x-1}[x=-3][4*t']\quad + \tabulate[rspec={x,1,3},rround=0,chnudge=9, + (pad)=2,signs=-1] + { e^x-1}[x=-3][4*t']\quad + \tabulate[rspec={x,1,3},rround=0,chnudge=9, + (pad)=2,signs=2] + { e^x-1}[x=-3][4*t']\medskip{} + +\noindent In \emph{HMF} Table 23.2 illustrates \verb`signs=-2`; Tables +10.1, 13.1, 14.1, 19.1 among many others illustrate \verb`signs=-1`; +and Tables 9.4, 10.6, 20.2, 22.11 among others illustrate \verb`signs=2`. + +However the \texttt{signs} key is not limited to the `t-notation'. +In the following tables where the notation is not used, positive values +for the key give appropriate results (I've included also the default +setting): +\begin{verbatim} + \tabulate[rspec={x,0.1,0.4},(pad)=2,signs=2] + { 10\sin 5x}[x=-0.4][*4]\qquad + \tabulate[rspec={x,0.1,0.4},(pad)=2,signs=1] + { 10\sin 5x}[x=-0.4][*4]\qquad + \tabulate[rspec={x,0.1,0.4},(pad)=2] + { 10\sin 5x}[x=-0.4][*4] +\end{verbatim} +$\Longrightarrow$ \tabulate[rspec={x,0.1,0.4},(pad)=2,signs=2] + { 10\sin 5x}[x=-0.4][*4]\qquad + \tabulate[rspec={x,0.1,0.4},(pad)=2,signs=1] + { 10\sin 5x}[x=-0.4][*4]\qquad + \tabulate[rspec={x,0.1,0.4},(pad)=2] + { 10\sin 5x}[x=-0.4][*4]\medskip{} + +\emph{HMF} seems to use \verb`signs=2` when the sign of function +values changes every few entries and \verb`signs=1` when there are +runs of entries of the same sign. They would use the middle table +of the three here. + +\subsection{Differences: \texttt{diffs}} + +In fine-grained tables where function values change only slowly from +entry to entry it can be helpful to include a difference entry between +function value entries as an aid to interpolation (and a test of eyesight). +By entering +\begin{lyxcode} +diffs~=~<non-negative~integer> +\end{lyxcode} +the \verb`tabulate` command will include differences in a table. +The \texttt{<non-negative integer>} is the maximum number of digits +in a difference. +\begin{verbatim} + \tabulate[rspec={x,0.01,1.05},rround=2, + rhnudge=9,chnudge=21,diffs=3] + { \sinh x }[x=1][*4] +\end{verbatim} +$\Longrightarrow$ \tabulate[rspec={x,0.01,1.05},rround=2, + rhnudge=9,chnudge=21,diffs=3] + { \sinh x }[x=1][*4]\medskip{} + +I have deliberately chosen the function and settings here \textendash{} +particularly \texttt{diffs=3} \textendash{} to give a good result. +It is easy to get this wrong. The evidence will be in the misalignment +of the first row of function values or unnecessary padding of differences +with leading zeros. It is a good idea to create your table first, +see how function values change between successive rows and judge how +many digits there will be in a difference. In the following examples +I have deliberately put \texttt{diffs=2} and \texttt{diffs=4} to show +the effect of a misjudgement. In the second table the function is +\emph{decreasing}, $-\sinh x$, to show how it is the absolute value +of the difference between successive function values that is tabulated. +A difference is always a non-negative value. +\begin{verbatim} + \tabulate[rspec={x,0.01,1.05},rround=2, + rhnudge=9,chnudge=21,diffs=2] + { \sinh x }[x=1][*4]\qquad + \tabulate[rspec={x,0.01,1.05},rround=2, + rhnudge=9,chnudge=21,diffs=4] + { -\sinh x }[x=1][*4] +\end{verbatim} +$\Longrightarrow$ \tabulate[rspec={x,0.01,1.05},rround=2, + rhnudge=9,chnudge=21,diffs=2] + { \sinh x }[x=1][*4]\qquad + \tabulate[rspec={x,0.01,1.05},rround=2, + rhnudge=9,chnudge=21,diffs=4] + { -\sinh x }[x=1][*4]\medskip{} + +\noindent When the \texttt{diffs} setting is too small, function values +in the first row are misaligned, the amount depending on how much +too small. When the \texttt{diffs} setting is too big, alignment is +fine but differences are padded with unnecessary leading zeros, meaning +the column header will need a bigger nudge to bring \emph{it} into +alignment. + +\subsection{Formatting special values: \texttt{Q?} and \texttt{A!}} + +You may wish to highlight or display in some special way a particular +function value or values. \verb`\nmcTabulate` has two related settings +that enable this: \texttt{Q?=<tokens>} and \texttt{A!=<tokens>}. As +the names suggest: Question? and Answer! + +The question should be an expression that \texttt{l3fp} can digest +and produce a boolean answer to (1 for `true' or 0 for `false'). +\texttt{numerica} uses \texttt{@} to denote the current function value, +so queries like \texttt{Q?=@<0} (Is the current function value negative?) +or \texttt{Q?=\{}@\texttt{>=pi\}} (Is the current function value greater +than or equal to $\pi$?) are valid questions. (Note the braces in +the second question, used to hide the equality sign.) Other possible +useful components of such questions are \texttt{exp(1)} for the number +$e$, || for logical Or, \texttt{\&\&} for logical And, and \texttt{!} +for logical Not,\texttt{ }as well as the familiar arithmetic symbols, +\texttt{+ - {*} /} and \texttt{\textasciicircum}, relation symbols +\texttt{< > =} and their combinations like \texttt{!= >= <=} etc., +and parentheses. For everything \texttt{l3fp} makes available see +the relevant chapter in \texttt{Interface3.pdf}, part of the documentation +that comes with the \LaTeX 3 package \texttt{l3kernel}. In addition +to these components, \texttt{numerica} offers \texttt{MAX} and \texttt{MIN} +which are the maximum and minimum function values tabulated, so that, +e.g., \texttt{Q?=\{@=MIN\}} (note the braces) is the question: Is +the current function value equal to the minimum function value for +the whole table? + +The answer must be in the form of a \LaTeXe{} formatting statement, +again using \texttt{@} to denote the current function value. Thus +\texttt{A!=\textbackslash mathbf\{@\}} is a valid answer; so is \texttt{A!=\textbackslash color\{red\}\{@\}} +(provided you have \texttt{\textbackslash usepackage\{color\}} in +the preamble); and so is \texttt{A!=(@)}. Another valid answer is +\texttt{A!=} , meaning that function values satisfying the \texttt{Q?} +question are omitted from the output. + +For example, suppose we wish to focus on the values of $\cos(m\pi/n)$ +lying between $0$ and $\tfrac{1}{2}$ inclusive for certain values +of $m$ and $n$. Rather than cluttering the table with values outside +that interval, we suppress them (the two occurrences of `\texttt{1e-14}' +in the query are there to prevent rounding errors confusing the result): +\begin{verbatim} + \tabulate + [rspec={n,1,15},rround=0,rpos=2,rules=Tth, + cspec={m,1,5},ctitle=*,chstyle=2, + Q?={@<-1e-14||@>0.5+1e-14},A!=] + { \cos(m\pi/n) }[n=4,m=2][*4] +\end{verbatim} +$\Longrightarrow$ \tabulate[rspec={n,1,15},rround=0,rpos=2,rules=Tth, + cspec={m,1,5},ctitle=*,chstyle=2, + Q?={@<-1e-14||@>0.5+1e-14},A!=] + { \cos(m\pi/n)}[n=4,m=2][*4] + +\section{Table placement} + +\label{sec:Table-placement}There is only one setting in this category +that is part of \texttt{numerica} as such, the tabular vertical alignment +option; see §\ref{subsec:Verticalalignment}. But \LaTeX{} allows one +to insert vertical space with its \verb`\bigskip`, \verb`\medskip`, +\verb`\smallskip`, usually about one line space, a half line space, +and a quarter line space (with stretch and shrink), and \verb`booktabs` +provides \verb`\abovetopsep` and \verb`\belowbottomsep`, both set +by default to \verb`0ex` (or any other unit you care to use) and +easily changed by writing, e.g., \verb`\abovetopsep=1.25ex` if you +want to insert \verb`1.25ex` of space above the table (perhaps to +fit captions). + +\subsection{Vertical~alignment} + +\label{subsec:Verticalalignment}By writing\texttt{ } +\begin{lyxcode} +valign~=~<char>~ +\end{lyxcode} +where \texttt{<char>} is one of \texttt{t} or \texttt{b} the vertical +alignment of the table can be set relative to the text baseline.\texttt{ valign=t +}aligns the top of the table with the text baseline, \texttt{valign=b} +the bottom of the table with the text baseline. By default (no \texttt{valign} +setting or \texttt{valign} equated to some character other than \texttt{t} +or \texttt{b}) the middle of the table is aligned with the text baseline. +Repeating an example from earlier (§\ref{sec:Row-variable-settings}) +I have added letters A, B, C to show where the baseline is. In the +first table the top of the table aligns with the baseline; in the +second table (default case) the middle of the table aligns with the +baseline; in the third table, the bottom of the table aligns with +the baseline. +\begin{verbatim} + A \tabulate[valign=t,rvar=x,rstep=0.2,rows=6] + { \sin x/\cos x }[x=0][*] \qquad + B \tabulate[rspec={x,0.2,1}] + { \tan x }[x=0][*] \qquad + C \tabulate[valign=b,rspec={x,0.2,(6)}] + { \sqrt{\sec^2 x - 1} }[x=0][*] +\end{verbatim} +$\Longrightarrow$ A \tabulate[valign=t,rvar=x,rstep=0.2,rows=6,rstop=2] + { \sin x/\cos x }[x=0][*] \qquad + B \tabulate[rspec={x,0.2,1}] + { \tan x }[x=0][*] \qquad + C \tabulate[valign=b,rspec={x,0.2,(6)}] + { \sqrt{\sec^2 x - 1} }[x=0][*]\medskip{} + +As explained in §\ref{subsec:Adjoining-tables}, tables can be adjoined +to give the appearance of a single larger table. If tables with different +numbers of rows are adjoined in this manner, then a middle alignment +fails and either a top or bottom alignment is necessary. + +\section{Star option} + +If the \texttt{Q?} question is satisfied by at least one function +value then adding a star (asterisk) to the \verb`\tabulate` command +will display the first such instance. I.e., like the other starred +commands, \verb`\eval*`, \verb`\iter*`, \verb`\solve*` and \verb`\recur*`, + \verb`\tabulate*` outputs a single number: +\begin{verbatim} + \tabulate* + [rspec={n,1,15},cspec={m,1,5}, + Q?={@<-1e-14||@>0.5+1e-14}] + { \cos(m\pi/n) }[n=4,m=2][*4] +\end{verbatim} +$\Longrightarrow$ \tabulate* + [rspec={n,1,15},cspec={m,1,5}, + Q?={@<-1e-14||@>0.5+1e-14}] + { \cos(m\pi/n) }[n=4,m=2][*4]. Ineed, if you omit the \texttt{Q?} and \texttt{A!} settings from +the previous table then this is the value that follows $0.5000$ in +the \texttt{m=2} column \textendash{} the first function value encountered +satisfying the query \texttt{Q?}. + +If \emph{no} function value satisfies the query then a message is +generated: +\begin{verbatim} + \tabulate* + [rspec={n,1,15},cspec={m,1,5}, + Q?=|@>1] + { \cos(m\pi/n) }[n=4,m=2][*4] +\end{verbatim} +$\Longrightarrow$ \tabulate* + [rspec={n,1,15},cspec={m,1,5}, + Q?=@>1] + { \cos(m\pi/n) }[n=4,m=2][*4] + +And if there is no query at all when the star option is chosen, another +message is shown: +\begin{verbatim} + \tabulate* + [rspec={n,1,15},cspec={m,1,5}] + { \cos(m\pi/n) }[n=4,m=2][*4] +\end{verbatim} +$\Longrightarrow$ \tabulate* + [ rspec={n,1,15}, cspec={m,1,5}] + { \cos(m\pi/n) }[n=4,m=2][*4] + +\subsection{Scientific notation} + +If you want the number output in scientific notation when the star +option is chosen, then enter the exponent mark in the trailing number-format +option. This is straightforward for a letter like the commonly used +\texttt{e}, but remember that if it is the \texttt{x} option that +you enter, then you will need to place the \verb`\tabulate*` command +between math delimiters, otherwise the \verb`\times` symbol resulting +from the \texttt{x} option will generate a \LaTeX{} error (`Missing +\$ inserted'): +\begin{verbatim} + $ + \tabulate* + [rspec={n,1,15},cspec={m,1,5}, + Q?={@<-1e-14||@>0.5+1e-14},A!=] + { \cos(m\pi/n) }[n=4,m=2][*4x] + $ +\end{verbatim} +$\Longrightarrow$ $ + \tabulate* + [rspec={n,1,15},cspec={m,1,5}, + Q?={@<-1e-14||@>0.5+1e-14},A!=] + { \cos(m\pi/n) }[n=4,m=2][*4x] + $. + +\section{The \texttt{reuse} setting} + +By entering +\begin{lyxcode} +reuse~=~<non-negative~integer> +\end{lyxcode} +it is possible to specify what is saved when the \verb`\tabulate` +command is followed by a \verb`\reuse` command. +\begin{itemize} +\item \texttt{reuse=0} saves the table as displayed (the default); +\item \texttt{reuse=n} saves the $n$-th \emph{column} of function values +\begin{itemize} +\item if \texttt{rpos} is non-zero: in a comma-separated list of braced +pairs \texttt{\{row-variable value,function value}\}; +\item if \texttt{rpos=0}: in a comma-separated list of function values. +\end{itemize} +\item \texttt{reuse=-n} saves the $n$-th \emph{row} of function values +in a comma-separated list that includes the row variable value in +its appropriate position(s) if \texttt{rpos} is non-zero. +\end{itemize} +In the following example the third row is saved to the control sequence +\verb`\rowiii` by using the setting \verb`reuse=-3`. +\begin{verbatim} + \tabulate + [rspec={x,0.25,(5)},rround=2,rhead=x,ralign=r,rhnudge=9, + cspec={k,0.25,(3)},chstyle=2, + chround=2,calign=r,ctitle=**, + rules=TthB,reuse=-3] + { a\sin kx }[a=2/\pi,{k}=3,{x}=0][*] \reuse[rowiii] +\end{verbatim} +$\Longrightarrow$ \tabulate + [rspec={x,0.25,(5)},rround=2, + rhead=x,ralign=r,rhnudge=9, + cspec={k,0.25,(3)},chstyle=2, + chround=2,calign=r,ctitle=**,rules=TthB,reuse=-3] + { a\sin kx }[a=2/\pi,{k}=3,{x}=0][*] \reuse[rowiii]\medskip{} + +\noindent Now test the content of the control sequence +\begin{lyxcode} +\noindent \verb`\rowiii`~$\Longrightarrow$~\rowiii ~ +\end{lyxcode} +\noindent You can see that indeed the third row has been `captured +for posterity'. + +Alternatively, we could save the second column in the control sequence +\verb`\colii`: +\begin{verbatim} + [rspec={x,0.25,(5)},rround=2,rhead=x,ralign=r,rhnudge=9, + cspec={k,0.25,(3)},chstyle=2, + chround=2,calign=r,ctitle=**, + rules=TthB,reuse=2] + { a\sin kx }[a=2/\pi,{k}=3,{x}=0][*] \reuse[colii] +\end{verbatim} +$\Longrightarrow$ \tabulate + [rspec={x,0.25,(5)},rround=2, + rhead=x,ralign=r,rhnudge=9, + cspec={k,0.25,(3)},chstyle=2, + chround=2,calign=r,ctitle=**,rules=TthB,reuse=2] + { a\sin kx }[a=2/\pi,{k}=3,{x}=0][*] \reuse[colii]\medskip{} + +To see what is saved in \verb`\colii` I use \TeX 's \verb`\meaning` +command to show that it is indeed braced pairs: +\begin{verbatim} + \meaning \colii +\end{verbatim} +$\Longrightarrow$ \meaning\colii + +\chapter{Nesting} + +\label{sec:tableNesting}Provided the starred form of any one of \verb`\eval`, +\verb`\iter`, \verb`\solve`, \verb`recur` actually does produce +a numerical result and not an error message then it can be nested +within the main argument of any one of the other commands, including +itself. The associated document \texttt{numerica-plus.pdf} has a number +of illustrations of this. The starred form can also be used in the +vv-list of any one of the commands, including itself. \texttt{numerica-plus.pdf} +has an example of \verb`\solve*` being used in the vv-list of an +\verb`\eval` command, and the document \texttt{numerica-basics.pdf} +shows examples of \verb`\eval*` being used in the vv-list of an \verb`\eval` +command. + +These nesting properties are also true of \verb`\tabulate`. It's +starred form can be used in other commands. Other commands' starred +forms can be used in \verb`\tabulate`. + +For the first, \verb`\tabulate*` inside \verb`\eval`, I have also +used the example to show how formatting settings (shown for the first +\verb`\tabulate*` in the example) can in fact be dispensed with (as +shown for the second \verb`\tabulate*`). Only \emph{functional} settings +are required. Hence there is no \verb`A!` setting in either. It is +the \emph{question}, \verb`Q?`, not the answer, that isolates the +single-value that is the result of \verb`\tabulate*`. +\begin{verbatim} + \eval{$ + (\tabulate* + [rspec={n,1,15},rround=0,rpos=2,rules=Tth, + cspec={m,1,5},ctitle=*,chstyle=2, + Q?={@=MAX}] + { \cos(m\pi/n) }[n=4,m=2][*4])\sinh t + + (\tabulate* + [rspec={n,1,15},cspec={m,1,5}, + Q?={@=MIN}] + { \sin(m\pi/n) }[n=4,m=2][*4])\cosh t + $}[t=2][4] +\end{verbatim} +$\Longrightarrow$ \eval{$ + (\tabulate* + [rspec={n,1,15},rround=0,rpos=2,rules=Tth, + cspec={m,1,5},ctitle=*,chstyle=2, + Q?={@=MAX}] + { \cos(m\pi/n) }[n=4,m=2][*4])\sinh t + + (\tabulate* + [rspec={n,1,15},rround=0,rpos=2,rules=Tth, + cspec={m,1,5},ctitle=*,chstyle=2, + Q?={@=MIN}] + { \sin(m\pi/n) }[n=4,m=2][*4])\cosh t + $}[t=2][4]. + +For using the starred forms of other commands inside \verb`\tabulate`, +it makes more sense to use one or more of \verb`\iter*`, \verb`\solve*` +or \verb`\recur*` inside \verb`\tabulate` than it does \verb`\eval*`, +but that assumes the reader is familiar with those com$\frac{}{}$mands +and that \texttt{numerica-plus.def} is loaded for this document, which +it is not. So, here is a rather pointless illustration of nesting +\verb`\eval*` in \verb`\tabulate`. (At least it is reassuring that +the values of $\Delta(N)$ are identical in the two columns.) +\begin{verbatim} + \tabulate[rspec={N,100,500},rround=0,ctitle=\Delta(N), + chead=eval*&direct] + { ,\eval*{ \sum_{n=1}^N 1/n-\ln N-\gamma }, + \sum_{n=1}^N 1/n-\ln N-\gamma }[N=100][4*] +\end{verbatim} +$\Longrightarrow$ \tabulate[rspec={N,100,500},rround=0,ctitle=\Delta(N), + chead=eval*&direct] + { ,\eval*{ \sum_{n=1}^N 1/n-\ln N-\gamma }, + \sum_{n=1}^N 1/n-\ln N-\gamma }[N=100][4*] + +\chapter{Reference summary} + +\section{Commands defined in \texttt{numerica-tables}} + +\texttt{\textbackslash nmcTabulate, \textbackslash tabulate} + +\section{Settings for \texttt{\textbackslash nmcTabulate}} + +\subsubsection*{Row variable specification §\ref{sec:Row-variable-settings}} +\begin{center} +\begin{center} +\begin{tabular}{ll>{\raggedright}p{4cm}>{\raggedright}p{3cm}} +\toprule +{\small key} & {\small type} & {\small meaning} & {\small comment}\tabularnewline +\midrule +{\small\texttt{rvar}} & {\small token(s)} & {\small row variable} & \tabularnewline +{\small\texttt{rstep}} & {\small real num.} & {\small step size} & \tabularnewline +{\small\texttt{rstop}} & {\small real num.} & {\small stop value} & \multirow{2}{3cm}{either {\small\texttt{rstop}}{\small{} or }{\small\texttt{rows}}{\small , +not both}}\tabularnewline +{\small\texttt{rows}} & {\small int} & {\small number of rows} & \tabularnewline +{\small\texttt{rspec}} & {\small comma list} & {\small\texttt{\{start}}{\small , }{\small\texttt{step}}{\small , }{\small\texttt{stop\}}}{\small{} +or }{\small\texttt{\{start}}{\small , }{\small\texttt{step}}{\small , +}{\small\texttt{(rows)\}}} & {\small short form spec.}\tabularnewline +\bottomrule +\end{tabular} +\par\end{center} +\par\end{center} + +\subsubsection*{Row variable column formatting §\ref{subsec:Row-var-col-formatting}} +\begin{center} +\begin{center} +\begin{tabular}{ll>{\raggedright}p{4cm}l} +\toprule +{\small key} & {\small type} & {\small meaning} & {\small default}\tabularnewline +\midrule +{\small\texttt{rround}} & {\small int} & {\small rounding} & {\small\texttt{1}}\tabularnewline +{\small\texttt{ralign}} & {\small char (}{\small\texttt{r/c/l}}{\small )} & {\small horizontal alignment} & {\small\texttt{r}}\tabularnewline +{\small\texttt{rfont}} & {\small chars} & {\small font (}{\small\verb`\math<chars>`}{\small )} & \tabularnewline +{\small\texttt{rhead}} & {\small tokens} & {\small header} & {\small\texttt{rvar}}\tabularnewline +{\small\texttt{rhnudge}} & int & {\small nudge header }{\small{\small\verb`<int>`}}{\small{} mu} & {\small\texttt{0}}\tabularnewline +{\small\texttt{rpos}} & {\small int (}{\small\texttt{0}}{\small\ldots}{\small\texttt{4}}{\small )} & {\small column position(s)} & {\small\texttt{1}}\tabularnewline +{\small\texttt{rvar'}} & {\small tokens} & {\small 2nd row variable col. spec.} & {\small\texttt{rvar}}\tabularnewline +{\small\texttt{rhead'}} & {\small tokens} & {\small header of 2nd rv col. (if it exists)} & {\small\texttt{rvar'}}\tabularnewline +{\small\texttt{rhnudge'}} & int & {\small nudge 2nd rv col. header }{\small{\small\verb`<int>`}}{\small{} +mu} & {\small\texttt{0}}\tabularnewline +\bottomrule +\end{tabular} +\par\end{center} +\par\end{center} + +\subsubsection*{Column variable specification §\ref{sec:Column-variable-settings}.} +\begin{center} +\begin{center} +\begin{tabular}{ll>{\raggedright}p{4cm}l} +\toprule +{\small key} & {\small type} & {\small meaning} & {\small default}\tabularnewline +\midrule +{\small\texttt{cvar}} & {\small token(s)} & {\small column variable} & \tabularnewline +{\small\texttt{cstep}} & {\small real num.} & {\small step size} & \tabularnewline +{\small\texttt{cstop}} & {\small real num.} & {\small stop value} & {\small either }{\small\texttt{cstop}}\tabularnewline +{\small\texttt{cols}} & {\small int} & {\small number of columns} & {\small or }{\small\texttt{cols}}{\small , not both}\tabularnewline +{\small\texttt{cspec}} & {\small comma list} & {\small\texttt{\{cvar,cstep}}{\small , }{\small\texttt{cstop\}}}{\small{} +or}{\small\texttt{ \{cvar,cstep}}{\small ,}{\small\texttt{(cols)\}}} & {\small short form spec.}\tabularnewline +\bottomrule +\end{tabular} +\par\end{center} +\par\end{center} + +\subsubsection*{Column variable header formatting §\ref{subsec:Column-header-formatting}.} +\begin{center} +\begin{center} +\begin{tabular}{ll>{\raggedright}p{4cm}l} +\toprule +{\small key} & {\small type} & {\small meaning} & {\small default}\tabularnewline +\midrule +{\small\texttt{chstyle}} & {\small int (0/1/2/3)} & {\small header style} & {\small\texttt{0}}\tabularnewline +{\small\texttt{ctitle}} & {\small tokens} & {\small single col. alternative header} & \tabularnewline +{\small\texttt{chead}} & {\small tokens} & {\small user-defined header} & \tabularnewline +{\small\texttt{calign}} & {\small char (r/c/l)} & {\small column alignment} & {\small\texttt{r}}\tabularnewline +{\small\texttt{chnudge}} & {\small int} & {\small nudge header }{\small{\small\verb`int`}}{\small{} mu} & {\small\texttt{0}}\tabularnewline +{\small\texttt{chround}} & {\small int} & {\small column header rounding} & {\small\texttt{0}}\tabularnewline +\bottomrule +\end{tabular} +\par\end{center}\newpage{} +\par\end{center} + +\subsubsection*{Function value formatting §\ref{sec:Function-value-formatting}.} +\noindent \begin{center} +\noindent \begin{center} +\begin{tabular}{cc>{\raggedright}p{4cm}c} +\toprule +{\small key} & {\small type} & {\small meaning} & {\small default}\tabularnewline +\midrule +{\small\texttt{(pad)}} & {\small int} & {\small (t-notation) phantom padding} & \tabularnewline +{\small\texttt{signs}} & {\small int} & {\small sign handling for function values} & {\small\texttt{0}}\tabularnewline +{\small\texttt{diffs}} & {\small int} & {\small insert differences \& pre-pad with zeros} & {\small\texttt{0}}\tabularnewline +{\small\texttt{Q?}} & {\small tokens} & {\small special cell conditional} & \tabularnewline +{\small\texttt{A!}} & {\small tokens} & {\small special cell formatting} & \tabularnewline +\bottomrule +\end{tabular} +\par\end{center} +\par\end{center} + +\subsubsection*{Whole-of-table formatting §\ref{sec:Whole-of-table-formatting}.} +\noindent \begin{center} +\noindent \begin{center} +\begin{tabular}{ll>{\raggedright}p{4cm}l} +\toprule +{\small key} & {\small type} & {\small meaning} & {\small default}\tabularnewline +\midrule +{\small\texttt{ctitle}} & {\small tokens} & {\small collective title for function-value columns} & \tabularnewline +{\small\texttt{rules}} & {\small chars} & {\small horizontal rules template} & {\small\texttt{ThB}}\tabularnewline +{\small\texttt{foot}} & {\small tokens} & {\small content of footer line} & \tabularnewline +{\small\texttt{rpos}} & {\small int (}{\small\texttt{0}}{\small\ldots}{\small\texttt{4}}{\small )} & {\small row-variable column position(s)} & {\small\texttt{1}}\tabularnewline +{\small\texttt{rbloc}} & {\small comma list} & {\small division of rows into blocks} & \tabularnewline +{\small\texttt{rblocsep}} & {\small length} & {\small extra spacing between blocks of rows} & {\small\texttt{1 ex}}\tabularnewline +\bottomrule +\end{tabular} +\par\end{center} +\par\end{center} + +\subsubsection*{Table placement §\ref{subsec:Verticalalignment}.} +\noindent \begin{center} +\noindent \begin{center} +\begin{tabular}{cc>{\raggedright}p{4cm}c} +\toprule +{\small key} & {\small type} & {\small meaning} & {\small default}\tabularnewline +\midrule +{\small\texttt{valign}} & {\small char (t/b)} & {\small vertical alignment} & \tabularnewline +\bottomrule +\end{tabular} +\par\end{center} +\par\end{center} +\end{document} |