texlive[41554] Master: diffcoeff (27jun16)

commits+karl at tug.org commits+karl at tug.org
Mon Jun 27 22:41:31 CEST 2016


Revision: 41554
          http://tug.org/svn/texlive?view=revision&revision=41554
Author:   karl
Date:     2016-06-27 22:41:31 +0200 (Mon, 27 Jun 2016)
Log Message:
-----------
diffcoeff (27jun16)

Modified Paths:
--------------
    trunk/Master/tlpkg/bin/tlpkg-ctan-check
    trunk/Master/tlpkg/tlpsrc/collection-mathextra.tlpsrc

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/diffcoeff/
    trunk/Master/texmf-dist/doc/latex/diffcoeff/README.txt
    trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeff.pdf
    trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeff.tex
    trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeffx.pdf
    trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeffx.tex
    trunk/Master/texmf-dist/tex/latex/diffcoeff/
    trunk/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff.sty
    trunk/Master/texmf-dist/tex/latex/diffcoeff/diffcoeffx.sty
    trunk/Master/tlpkg/tlpsrc/diffcoeff.tlpsrc

Added: trunk/Master/texmf-dist/doc/latex/diffcoeff/README.txt
===================================================================
--- trunk/Master/texmf-dist/doc/latex/diffcoeff/README.txt	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/diffcoeff/README.txt	2016-06-27 20:41:31 UTC (rev 41554)
@@ -0,0 +1,23 @@
+README file for LaTeX package: diffcoeff
+
+Author: Andrew Parsloe (aparsloe at clear.net.nz) 2016-06-27
+
+diffcoeff.sty allows the easy writing of ordinary and partial differential 
+coefficients of arbitrary order. For mixed partial derivatives, the overall 
+order (algebraic or numeric) is calculated by the package. Optional arguments 
+allow the easy specification of a point of evaluation for ordinary 
+derivatives, or variables held constant for partial derivatives, and the 
+placement of the differentiand (in the numerator or appended). Some tweaking 
+of the display is possible through key = value settings. Secondary commands 
+provide analogous coefficients constructed from D, \Delta and \delta and a 
+command for writing Jacobians. 
+
+diffcoeffx.sty is diffcoeff.sty 'on steroids', extending that package in ways 
+that are probably unnecessary but have a certain logical forece. 
+
+The packages require the LaTeX3 bundles, l3kernel and l3packages.
+
+There are six files plus this README: diffcoeff.tex, diffcoeff.pdf (compiled 
+from diffcoeff.tex), and diffcoeff.sty; and diffcoeffx.tex, diffcoeffx.pdf 
+and diffcoeffx.sty. The tex and pdf files should be placed in texmf/doc/
+latex/diff, and the sty files in texmf/tex/latex/diff.
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/latex/diffcoeff/README.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeff.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeff.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeff.pdf	2016-06-27 20:40:03 UTC (rev 41553)
+++ trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeff.pdf	2016-06-27 20:41:31 UTC (rev 41554)

Property changes on: trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeff.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeff.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeff.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeff.tex	2016-06-27 20:41:31 UTC (rev 41554)
@@ -0,0 +1,1188 @@
+%% LyX 2.2.0 created this file.  For more info, see http://www.lyx.org/.
+%% Do not edit unless you really know what you are doing.
+\documentclass[english,extend]{article}
+\usepackage{lmodern}
+\renewcommand{\sfdefault}{lmss}
+\renewcommand{\ttdefault}{lmtt}
+\usepackage[T1]{fontenc}
+\usepackage[latin9]{inputenc}
+\setcounter{secnumdepth}{2}
+\setcounter{tocdepth}{2}
+\usepackage{booktabs}
+\usepackage{amstext}
+
+\makeatletter
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
+%% Because html converters don't know tabularnewline
+\providecommand{\tabularnewline}{\\}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
+ \newenvironment{example}{\begin{center}\ttfamily}{\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}}
+\newcommand{\strong}[1]{\textbf{#1}}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
+\usepackage{diffcoeff}
+
+\@ifundefined{showcaptionsetup}{}{%
+ \PassOptionsToPackage{caption=false}{subfig}}
+\usepackage{subfig}
+\makeatother
+
+\usepackage{babel}
+\begin{document}
+
+\title{\texttt{diffcoeff}~\\
+a \LaTeX{} package for writing\texttt{}~\\
+differential coefficients easily}
+
+\author{Andrew Parsloe\\
+{\small{}(aparsloe at clear.net.nz)}}
+\maketitle
+\begin{abstract}
+\noindent \texttt{diffcoeff.sty} allows the easy writing of ordinary and
+partial differential coefficients of arbitrary (algebraic or numeric) order.
+For mixed partial derivatives, the overall order (the superscript on $\partial$
+in the numerator) is calculated by the package. Optional arguments allow
+the easy specification of a point of evaluation for ordinary derivatives,
+or variables held constant for partial derivatives, and the placement of
+the differentiand (in the numerator or appended). Some tweaking of the
+display is possible through key = value settings. Secondary commands provide
+analogous coefficients constructed from $D,\thinspace\Delta,$ and $\delta$,
+and a command for writing Jacobians. The package uses \texttt{expl3} and
+\texttt{xparse} from the \LaTeX{}3 bundles, \texttt{l3kernel} and \texttt{l3packages}.
+\end{abstract}
+
+\section{Requirements}
+
+The \LaTeX{} package \texttt{diffcoeff.sty} is written in the expl3 language
+of \LaTeX{}3\texttt{ }and requires the bundles \texttt{l3kernel} and \texttt{l3packages}
+(the latter for the \texttt{xparse} module). However, granted the presence
+of these bundles in your \TeX{} distribution, the \LaTeX{}3 element should
+be invisible to the user. 
+
+The package is invoked in the usual way by entering
+\begin{lyxcode}
+\textbackslash{}usepackage\{diffcoeff\}
+\end{lyxcode}
+in the preamble of your document.
+
+\paragraph{Note on terminology}
+
+I refer throughout to the quantity or function being differentiated as
+the \emph{differentiand} (in line with \emph{integrand}, \emph{operand},
+etc.).
+
+\section{Ordinary differential coefficients \label{sec:Ordinary-differential-coefficien}}
+
+Writing\textbf{ }\texttt{\textbackslash{}diff\{y\}\{x\}} will produce $\diff{y}{x}$
+in text style (i.e. placed between \texttt{\$ \$}) or 
+\[
+\diff{y}{x}
+\]
+in display style (i.e. placed between \texttt{\textbackslash{}{[} \textbackslash{}{]}}
+). In fact \texttt{\textbackslash{}diff yx} (omitting the braces) will
+produce these results, with a saving on keystrokes. The braces are needed
+only when differentiand or variable of differentiation is more than a single
+token.
+
+There is one other form: we can insert a slash, `/', between numerator
+and denominator: \texttt{\textbackslash{}diff f/x} produces $\diff f/x$
+which may be preferred for textstyle differential coefficients on occasion.
+Nothing is gained in this particular instance. It is quicker to type the
+five keystrokes d, f, /, d, x than it is to type the nine of \textbackslash{},
+d, i, f, f, , f, /, x but there are occasions when this is not always the
+case. 
+
+An optional first argument allows the order of differentiation to be specified.
+The order need not be a number; an algebraic order of differentiation is
+perfectly acceptable or, indeed, a mix:
+\begin{example}
+\textbackslash{}diff{[}2{]}\{y\}\{x\} $\Longrightarrow\quad{\displaystyle \diff[2]{y}{x},}$\medskip{}
+
+\textbackslash{}diff{[}n+1{]}\{y\}\{x\} $\Longrightarrow\quad{\displaystyle \diff[n+1]{y}{x}}.$
+\end{example}
+(And again the braces can be omitted for single letters like \textbf{x}
+and \textbf{y}.)
+
+In slash style, \texttt{\textbackslash{}diff{[}2{]}f/x} (11 keystrokes)
+produces $\diff[2]f/x$, not significantly more typing than \texttt{d\textasciicircum{}2f/dx\textasciicircum{}2}
+(9 keystrokes).
+
+If you want to specify a point at which the derivative is evaluated, append
+a final optional argument, but note that it is given in \emph{braces} rather
+than square brackets:
+\begin{example}
+\textbackslash{}diff{[}2{]}\{y\}\{x\}\{0\} $\Longrightarrow\quad{\displaystyle \diff[2]{y}{x}{0}}$
+\end{example}
+\noindent (In this example it seems neater \emph{not} to finish with a
+full stop or other punctuation.) The use of braces means that the differential
+coefficient can be followed immediately by a mathematical expression wrapped
+in \texttt{\textbackslash{}\{ \textbackslash{}\}}, or \texttt{{[} {]}},
+without the expression being confused with the (final) optional argument.
+Note also that there must be \emph{no space} before the argument: it follows
+\emph{immediately} on the second mandatory argument (if it follows at all). 
+
+We could save a few keystrokes by writing this last example as \texttt{\textbackslash{}diff{[}2{]}yx\{0\}}.
+The braces around the final optional argument can \emph{not} be omitted
+\textendash{} otherwise there is no way of knowing that it \emph{is }the
+final optional argument and not part of a following expression.
+
+In slash style, the trailing optional argument can be used, but perhaps
+should not be. It looks ugly: 
+\begin{example}
+\textbackslash{}diff{[}2{]}y/x\{0\} $\Longrightarrow\quad{\displaystyle \diff[2]{y}/{x}{0}}$
+\end{example}
+Slash style is a more casual rendering of the derivative, intended for
+inline use within text and it would be better to use a phrase like `evaluated
+at zero'.
+
+\subsection{\textbackslash{}diffset: formatting tweaks}
+
+There are a number of tweaks one can make to the display of a derivative.
+Many people now use upright (roman) forms for the `d's of a differential
+coefficient, rather than math italic. To do this, put the command 
+\begin{example}
+{\footnotesize{}\textbackslash{}}diffset{[}roman = true{]}
+\end{example}
+\noindent in the preamble of your document (following the \texttt{\textbackslash{}usepackage\{diffcoeff\}}
+of course). The default is math italic.
+
+It is possible that you may want more space between the `d' in the numerator
+of a differential coefficient and the superscripted order of the derivative.
+Using an upright `d' alleviates this problem, but if using the default
+math italic for the `d's, the separation can be altered by using the 
+\begin{example}
+\textbackslash{}diffset{[}d-sep = $n${]}
+\end{example}
+\noindent command which adds an extra $n$~mu to \TeX{}'s spacing. The
+default value for $n$ is 1 (i.e. 1~mu). The new separation will affect
+all derivatives following the new setting. Put in the preamble, the new
+separation will be document-wide.
+
+A third tweak changes the delimiters used to indicate the point of evaluation.
+By default there is nothing on the left side and a vertical rule with the
+point of evaluation subscripted to it on the right. You may prefer subscripted
+parentheses. In that case write
+\begin{example}
+\textbackslash{}diffset{[}d-delims~=~(){]}\textmd{.}
+\end{example}
+Whatever delimiters you choose need to work with \LaTeX{}'s \texttt{\textbackslash{}left}
+and \texttt{\textbackslash{}right} commands and consist of exactly two
+tokens. \texttt{{[}} and \texttt{{]}}\textbf{ }are acceptable as also are
+pairs like \texttt{\textbackslash{}lceil \textbackslash{}rceil}, \texttt{\textbackslash{}lfloor
+\textbackslash{}rfloor} but if you want to use \texttt{\textbackslash{}\{}\textbf{
+}and\textbf{ }\texttt{\textbackslash{}\}} you need to place the \texttt{\textbackslash{}diffset}
+command between maths delimiters. The default pair, as indicated, is \texttt{. |},
+t or full stop being \LaTeX{}'s way of suppressing (in this case) the
+left delimiter. 
+
+If you change the delimiters, say to \textbf{( )}, then the position of
+the subscript may need adjusting. To do this, use the command
+\begin{example}
+\textbackslash{}diffset{[}d-nudge = $n${]}
+\end{example}
+A suggested setting for parentheses \textbf{( )} is $-6$ (in fact $-6$~mu
+but the `mu' is supplied by \texttt{diffcoeff}). Thus the total change
+would be
+\begin{example}
+\textbackslash{}diffset{[}d-delims = ( ), d-nudge = -6{]}
+\end{example}
+producing, for example,
+\begin{example}
+\textbackslash{}diff{[}n{]}\{y\}\{x\}\{0\} $\diffset[d-delims=(),d-nudge=-6]\Longrightarrow\quad{\displaystyle \diff[n]{y}{x}{0}}.$
+\end{example}
+The default setting for \textbf{. |} is 0. Simply writing
+\begin{example}
+\textbackslash{}diffset $\diffset$
+\end{example}
+will return all settings to their defaults.
+
+\subsection{Variations}
+
+\subsubsection{Appending the differentiand: \textbackslash{}diff{*}}
+
+If you want the differentiand to follow the differential coefficient rather
+than sit in the numerator, perhaps because it is a fraction itself or because
+it is long, like a polynomial ($ax^{2}+bx+c$), then one way to achieve
+that is to leave the first mandatory argument in the \texttt{\textbackslash{}diff}
+command empty and immediately follow the differential operator with the
+differentiand:
+\begin{example}
+\textbackslash{}diff\{\}\{x\}(ax\textasciicircum{}2+bx+c) $\Longrightarrow\quad{\displaystyle \diff{}{x}(ax^{2}+bx+c)}.$
+\end{example}
+Another is to use the star form of the \texttt{\textbackslash{}diff }command,
+\begin{example}
+\textbackslash{}diff{*}{[}2{]}\{\textbackslash{}frac\{F(x)\}\{G(x)\}\}\{x\}
+$\Longrightarrow\quad{\displaystyle \diff*[2]{\frac{F(x)}{G(x)}}{x}.}$ 
+\end{example}
+\noindent The LaTeX expression can be harder to read if, as here, one is
+using a command like \texttt{\textbackslash{}frac} with its own pairs of
+braces, but it is much easier, if one isn't sure whether the differentiand
+should be appended or in the numerator, simply to insert or delete an asterisk
+than move the differentiand from one place to the other. The star form
+becomes especially useful if you want to both append the differentiand
+\emph{and }indicate the point of evaluation, since it saves having to set
+up the \texttt{\textbackslash{}left.} and \texttt{\textbackslash{}right|}\textbf{
+}delimiters and the subscript:
+\begin{example}
+\textbackslash{}diff{*}\{\textbackslash{}frac\{F(x)\}\{G(x)\}\}\{x\}\{0\}
+$\Longrightarrow\quad{\displaystyle \diffset[d-delims=.|,d-nudge=0]\diff*{\frac{F(x)}{G(x)}}{x}{0}}$ 
+\end{example}
+In slash style with the star option, an example above becomes
+\begin{example}
+\textbackslash{}diff{*}\{(ax\textasciicircum{}2+bx+c)\}/\{x\} $\Longrightarrow\quad\text{\ensuremath{{\displaystyle \diff*{(ax^{2}+bx+c)}/{x}}}}$, 
+\end{example}
+where the derivative is automatically enclosed in parentheses by \texttt{diffcoeff}.
+
+\subsubsection{Multi-character variables of differentiation}
+
+Derivatives of a function-of-a-function may require forming a differential
+coefficient in which the variable of differentiation is more complicated
+than a single symbol like \texttt{x} or \texttt{\textbackslash{}alpha}.
+For instance, to differentiate $\ln x^{2}$ (the logarithm of $x^{2}$)
+one first differentiates in $x^{2}$ then in $x$. The initial differentiation
+can be rendered
+\begin{example}
+\textbackslash{}diff\{\textbackslash{}ln x\textasciicircum{}2\}\{x\textasciicircum{}2\}
+$\Longrightarrow\quad{\displaystyle \diff{\ln x^{2}}{x^{2}}}$; \medskip{}
+
+diff\{\textbackslash{}ln x\textasciicircum{}2\}/\{x\textasciicircum{}2\}
+$\Longrightarrow\quad{\displaystyle \diff{\ln x^{2}}/{x^{2}}}.$ 
+\end{example}
+\noindent Because of the superscript in the variable of differentiation
+$x^{2}$, parentheses have been automatically inserted in the denominator.
+This does not happen in a first-order derivative unless there is a superscript
+present. For instance,
+\begin{example}
+\textbackslash{}diff\{\textbackslash{}ln\textbackslash{}sin x\}\{\textbackslash{}sin
+x\} $\Longrightarrow\quad{\displaystyle \diff{\ln\sin x}{\sin x}.}$ 
+\end{example}
+\noindent displays without parentheses. However, for higher order derivatives
+parentheses are \emph{always} inserted to avoid confusion:
+\begin{example}
+\textbackslash{}diff{[}2{]}\{\textbackslash{}ln\textbackslash{}sin x\}\{\textbackslash{}sin
+x\} $\Longrightarrow\quad{\displaystyle \diff[2]{\ln\sin x}{\sin x}.}$ 
+\end{example}
+
+\paragraph{Positioning the d in the numerator}
+
+When appending a differentiand, you may want to change the position of
+the `d' in the numerator, particularly if the variable of differentiation
+is a multi-character symbol or the order of differentiation is a multi-character
+value like $n+1$. 
+
+If you `manually' append the differentiand, then there are various ways
+of altering the placement of the `d' from the default midpoint: use \texttt{\textbackslash{}hfill}
+to push it hard to the left; use \texttt{\textbackslash{}hfil} to\textbf{
+}push it to the left an intermediate amount; use \texttt{\textbackslash{}hphantom}
+or \texttt{\textbackslash{}hspace}, both with a braced argument, to push
+it to the left some custom amount; use \texttt{\textbackslash{}hspace}\textbf{
+}with a \emph{negative} braced argument to push it to the right.\emph{
+}These same means can be used to shift the `d' when using the starred
+form of \texttt{\textbackslash{}diff}.\textbf{ }The effect is exactly the
+same, too:
+\begin{example}
+\textbackslash{}diff{[}n+1{]}\{\textbackslash{}hphantom\{\textbackslash{}sin
+x\}\}\{\textbackslash{}sin x\}\textbackslash{}ln\textbackslash{}sin x $\Longrightarrow\quad{\displaystyle \diff[n+1]{\hphantom{\sin x}}{\sin x}\ln\sin x},$\medskip{}
+
+\textbackslash{}diff{*}{[}n+1{]}\{\textbackslash{}hphantom\{\textbackslash{}sin
+x\}\textbackslash{}ln\textbackslash{}sin x\}\{\textbackslash{}sin x\} $\Longrightarrow\quad{\displaystyle \diff*[n+1]{\hphantom{\sin x}\ln\sin x}{\sin x}}.$
+\end{example}
+\noindent In the starred form \texttt{diffcoeff} understands that the formatting
+is not appended with the differentiand but stays in the numerator. (But
+a \emph{second} \texttt{\textbackslash{}hphantom} or \texttt{\textbackslash{}hfil}
+etc. would be appended.) These are to be compared with
+\begin{example}
+\textbackslash{}diff{*}{[}n+1{]}\{\textbackslash{}ln\textbackslash{}sin
+x\}\{\textbackslash{}sin x\} $\Longrightarrow\quad{\displaystyle \diff*[n+1]{\ln\sin x}{\sin x},}$
+\end{example}
+where no phantom has been used. Which is better? Deleting the asterisk
+gives
+\begin{example}
+\textbackslash{}diff{[}n+1{]}\{\textbackslash{}ln\textbackslash{}sin x\}\{\textbackslash{}sin
+x\} $\Longrightarrow\quad{\displaystyle \diff[n+1]{\ln\sin x}{\sin x},}$
+\end{example}
+In slash style, the phantom (or \texttt{\textbackslash{}hfil} etc.) is
+ignored:
+\begin{example}
+\textbackslash{}diff{*}{[}n+1{]}\{\textbackslash{}hphantom\{\textbackslash{}sin
+x\textbackslash{}sin x\textbackslash{}sin x\}\textbackslash{}ln\textbackslash{}sin
+x\}/\{\textbackslash{}sin x\} $\Longrightarrow\quad{\displaystyle \diff*[n+1]{\hphantom{\sin x\sin x\sin x}\ln\sin x}/{\sin x}}.$
+\end{example}
+
+\subsubsection{Iterated derivatives}
+
+A second derivative is an iterated derivative, i.e., one in which a differential
+coefficient forms the differentiand of another differential coefficient:
+\begin{example}
+\textbackslash{}diff{[}2{]}yx = \textbackslash{}diff{*}\{\textbackslash{}diff
+yx\}x $\Longrightarrow{\displaystyle \diff[2]yx=\diff*{\diff yx}x},$
+\end{example}
+or even
+\begin{example}
+\textbackslash{}diff{[}2{]}yx = \textbackslash{}diff\{\textbackslash{}diff
+yx\}x $\Longrightarrow{\displaystyle \diff[2]yx=\diff{\diff yx}x},$
+\end{example}
+where omission of unnecessary braces has aided readability. Note how easy
+it is to switch between the different forms on the right, simply by inserting
+or removing an asterisk. 
+
+\subsection{Forming `derivatives' with D, \textbackslash{}Delta, \textbackslash{}delta}
+
+Often one wants to construct analogues of a differential coefficient but
+with symbols other than $d$ or $\partial$. The \texttt{diffcoeff} package
+offers three alternatives, all with the same pattern of optional and mandatory
+arguments as for \texttt{\textbackslash{}diff}, except for the slash form.
+There is \emph{no} slash option.
+
+An uppercase $D$ is used in place of $d$ for the \emph{material} or \emph{substantive}
+derivative of a quantity in (for example) fluid dynamics. Write \texttt{\textbackslash{}Diff}
+to invoke this command:\footnote{The \texttt{\textbackslash{}diffp} command, the partial derivative, in
+the example is discussed in the next section.}
+\begin{example}
+\textbackslash{}Diff\{\textbackslash{}rho\}\{t\}=\textbackslash{}diffp\textbackslash{}rho
+t + \textbackslash{}mathbf\{u\textbackslash{}cdot\}\textbackslash{}nabla\textbackslash{}rho
+$\Longrightarrow{\displaystyle \Diff{\rho}{t}=\diffp\rho t+\mathbf{u\cdot}\nabla\rho.}$ 
+\end{example}
+(The braces could also be removed from the arguments of \texttt{\textbackslash{}Diff}
+as they have been from the arguments of \texttt{\textbackslash{}diffp}.)\texttt{ }
+
+The `D's are romanised (along with the `d's of ordinary derivatives)
+with the 
+\begin{example}
+\textbackslash{}diffset{[}roman = true{]}
+\end{example}
+command. The default is math italic.
+
+The command \texttt{\textbackslash{}diffd} will form a fraction often used
+in introductory calculus texts (and other places):\footnote{I considered using \texttt{\textbackslash{}diffg} for this command as in
+`diff greek' but decided that the more likely mind-phrase is `diff delta',
+leading to the use of `d' rather than `g'.}
+\begin{example}
+\textbackslash{}diffd\{y\}\{x\} $\Longrightarrow{\displaystyle \diffd yx.}$ 
+\end{example}
+Similarly, \texttt{\textbackslash{}Diffd} forms a fraction with $\Delta$:
+\begin{example}
+\textbackslash{}Diffd\{y\}\{x\} $\Longrightarrow{\displaystyle \Diffd{y}{x}.}$ 
+\end{example}
+Higher order forms of these derivatives are produced in the same way as
+with \texttt{\textbackslash{}diff}, using an optional argument to specify
+the order:
+\begin{example}
+\textbackslash{}diffd{[}2{]}\{y\}\{x\} $\Longrightarrow{\displaystyle \diffd[2]yx.}$ 
+\end{example}
+A final optional argument, enclosed in braces, specifies a point of evaluation,
+care being taken, as ever, to ensure that there is no space between it
+and the second mandatory argument:
+\begin{example}
+\textbackslash{}Diffd\{y\}\{x\}\{x=0\} $\Longrightarrow{\displaystyle \Diffd yx{x=0}.}$ 
+\end{example}
+
+\section{Partial differential coefficients\label{sec:Partial-differential-coefficient}}
+\noindent \begin{flushleft}
+Partial differential coefficients follow the same pattern as for ordinary
+derivatives, with some generalisations arising from the greater possibilities.
+The command this time is \texttt{\textbackslash{}diffp}. Thus \textbf{\textbackslash{}diffp\{F\}\{x\}}
+produces $\diffp{F}{x}$ in text style and 
+\[
+\diffp{F}{x}
+\]
+ in display style. Braces can be omitted for single token differentiands
+and variables: \texttt{\textbackslash{}diffp Fx} does the job.\textbf{
+}As for \texttt{\textbackslash{}diff}, there is a slash form for more casual
+use: \texttt{\textbackslash{}diffp F/x} displaying as $\diffp F/x$. Given
+that \texttt{\textbackslash{}partial} takes 8 keystrokes to type, the slash
+form \emph{does }economise on keystrokes for a partial derivative.
+\par\end{flushleft}
+
+\begin{flushleft}
+Again an optional argument allows the specification of the order of differentiation
+and it may be numeric or algebraic or a mix of the two. For a second or,
+indeed, an $n+4$th-order partial derivative, 
+\par\end{flushleft}
+\begin{example}
+\textbackslash{}diffp{[}n+4{]}\{F\}\{x\} $\Longrightarrow\quad{\displaystyle {\displaystyle \diffp[n+4]{F}{x},}}$\medskip{}
+
+\textbackslash{}diffp{[}n+4{]}\{F\}/\{x\} $\Longrightarrow\quad{\displaystyle {\displaystyle \diffp[n+4]{F}/{x},}}$
+\end{example}
+In a subject like thermodynamics, there is a need to indicate which variable
+or variables are held constant when the differentiation occurs. To show
+this, append a final optional argument. Thus to differentiate the entropy
+$S$ in the temperature $T$ while holding the volume $V$ constant, write
+\begin{example}
+\textbackslash{}diffp\{S\}\{T\}\{V\} $\Longrightarrow\quad{\displaystyle \diffp{S}{T}{V}}$
+\end{example}
+As with \texttt{\textbackslash{}diff}\textbf{ }note how the final optional
+argument is given in braces rather than square brackets, and that there
+must be \emph{no space} before the argument: if used, it follows \emph{immediately}
+on the second mandatory argument. This means that the differential coefficient
+can be followed immediately by a mathematical expression wrapped in \textbackslash{}\{
+\textbackslash{}\}, or {[} {]}, without the expression being confused with
+the (final) optional argument.
+
+We could save a few keystrokes by writing this last example as \texttt{\textbackslash{}diffp
+ST\{V\}}. The braces around the optional argument can \emph{not} be dispensed
+with (otherwise there is no way of knowing that it \emph{is} the final
+optional argument and not part of a following expression). 
+
+Note that for the slash form of the derivative it is anticipated that there
+will be no trailing optional argument. If you \emph{do} use one, you will
+need to change the nudge value either with the \texttt{\textbackslash{}diffset}
+command or, better, by including a spacing command in the third argument:
+\begin{example}
+\textbackslash{}diffp\{S\}/\{T\}\{\textbackslash{};V\} $\Longrightarrow\quad{\displaystyle \diffp{S}/{T}{\;V}}$
+\end{example}
+Without the spacing command, the subscript encroaches on the right parenthesis.
+
+\subsubsection{Appending the differentiand}
+
+If you want to remove the differentiand from the numerator to instead follow
+the derivative, one way, as for ordinary derivatives, is to leave the first
+mandatory argument empty and manually append the differentiand:
+\begin{example}
+\textbackslash{}diffp{[}n{]}\{\}xf(x) $\Longrightarrow\quad{\displaystyle \diffp[n]{}xf(x).}$
+\end{example}
+However, you may wonder how that would look with the differentiand in the
+numerator, which is a good reason for preferring the starred form of the
+\texttt{\textbackslash{}diffp} command to achieve an appended derivative:
+\begin{example}
+\textbackslash{}diffp{*}{[}n{]}\{f(x)\}x $\Longrightarrow\quad{\displaystyle \diffp*[n]{f(x)}x.}$
+\end{example}
+Now it is easy to switch between an appended differentiand and one in the
+numerator simply by inserting or deleting the asterisk. In the slash form,
+parentheses are automatically inserted around the differential operator:
+\begin{example}
+\textbackslash{}diffp{*}{[}n{]}\{f(x)\}/x $\Longrightarrow\quad{\displaystyle \diffp*[n]{f(x)}/x.}$
+\end{example}
+It also happens, for example in thermodynamics, that you may wish to both
+append the differentiand \emph{and} indicate variables held constant. In
+that case, the starred \texttt{\textbackslash{}diffp} command is much easier
+to use. Thus, to express a relation in thermodynamics,
+\begin{example}
+\textbackslash{}diffp{*}\{\textbackslash{}frac \{P\}\{T\}\}\{U\}\{V\} =
+\textbackslash{}diffp{*}\{\textbackslash{}frac\{1\}\{T\}\}\{V\}\{U\} $\Longrightarrow\quad{\displaystyle \diffp*{\frac{P}{T}}{U}{V}=\diffp*{\frac{1}{T}}{V}{U}}$
+\end{example}
+\noindent where the starred form automatically takes care of the parentheses
+and subscripts. Again, not all the braces are necessary, with some help
+to readability:
+\begin{example}
+\textbackslash{}diffp{*}\{\textbackslash{}frac PT\}U\{V\} = \textbackslash{}diffp{*}\{\textbackslash{}frac
+1T\}V\{U\} $\Longrightarrow\quad{\displaystyle \diffp*{\frac{P}{T}}U{V}=\diffp*{\frac{1}{T}}V{U}}$
+\end{example}
+
+\subsection{Mixed partial derivatives}
+
+The new thing with partial derivatives, not present with ordinary derivatives,
+is \emph{mixed} partial derivatives, where there is more than one variable
+of differentiation. If each variable is differentiated only to the first
+order, then it is easy to specify the derivative. Say $f(x,y,z)$ is a
+function of three variables, as indicated. Then
+\begin{example}
+\textbackslash{}diffp\{f\}\{x\c{,}y,z\} $\Longrightarrow\quad{\displaystyle \diffp{f}{x,y,z}}.$
+\end{example}
+The variables of differentiation are listed in order in a comma list forming
+the second mandatory argument. The total order of differentiation (3 in
+this example) is inserted automatically \textendash{} \texttt{diffcoeff}
+does the calculation itself. There is also a slash form:
+\begin{example}
+\textbackslash{}diffp\{f\}/\{x\c{,}y,z\} $\Longrightarrow\quad{\displaystyle \diffp{f}/{x,y,z}}.$
+\end{example}
+If we want to differentiate variables to higher order, then their orders
+need to be specified explicitly. To do so use a comma list also in the
+\emph{optional} argument:
+\begin{example}
+\textbackslash{}diffp{[}2,3{]}\{f\}\{x,y,z\} $\Longrightarrow\quad{\displaystyle \diffp[2,3]{f}{x,y,z}.}$
+\end{example}
+\noindent Notice that the overall order of the derivative \textendash{}
+6 \textendash{} is again automatically calculated and inserted as a superscript
+on the $\partial$ symbol in the numerator. In this example, the comma
+list of orders has only two members, even though there are three variables.
+It is assumed that the orders given in the comma list of orders apply in
+sequence to the variables, the first order to the first variable, the second
+to the second variable, and so on, and that any subsequent orders not listed
+in the optional argument are, by default, 1. Thus we need to specify only
+2 and 3 in the example; the order of $z$ is 1 by default.
+
+But you \emph{cannot} use an order specification like \texttt{{[},,2{]}}.
+This will be treated as if it were \texttt{{[}2{]}}. (This is a feature
+of comma lists in the expl3 language used by \texttt{diffcoeff.sty}.) Instead
+write \texttt{{[}1,1,2{]}}.\textbf{ }It is only the \emph{tail} of an order
+specification which can be omitted.
+
+The automatic calculation of the overall order of differentiation remains
+true even when some or all of the orders for the individual variables are
+algebraic. For example, differentiating in three variables with orders
+\texttt{2k}, \texttt{m-k-2}, \texttt{m+k+3}, we have 
+\begin{example}
+\textbackslash{}diffp{[}2k-1,m-k-2,m+k+3{]}\{F(x,y,z)\}\{x,y,z\} $\Longrightarrow\quad{\displaystyle \diffp[2k-1,m-k-2,m+k+3]{F(x,y,z)}{x,y,z}}$,
+\end{example}
+
+\subsection{The order-override option}
+
+In this example the overall order is presented as \texttt{2k+2m}. You might
+prefer this to be presented as \texttt{2(k+m)} instead. Although \texttt{diffcoeff}
+takes some steps to present the overall order appropriately, it does not
+factorise expressions. If you want to present the order in a manner distinct
+from that of \texttt{diffcoeff}, use the\emph{ order-override option},
+which is a second optional argument immediately following the first:
+\begin{example}
+\textbackslash{}diffp{[}2k-1,m-k-2,m+k+3{]}{[}2(k+m){]}\{F(x,y,z)\}\{x,y,z\}
+$\Longrightarrow\quad{\displaystyle \diffp[2k-1,m-k-2,m+k+3][2(m+k)]{F(x,y,z)}{x,y,z}}$.
+\end{example}
+The order-override option does exactly that: overrides the presentation
+of the calculated order with the manually given one. (In fact the algorithm
+does not get called at all.)
+
+\subsubsection{Order specifications beyond the scope of \texttt{diffcoeff.sty}}
+
+The order specification can include signed integers, variables like $k$
+and $\alpha$ with signed integer coeffients, and products of any number
+of variables like $mn$ or $kmn$ with signed integer coefficients. The
+algorithm that calculates the overall order in \texttt{diffcoeff.sty} \emph{cannot}
+handle\texttt{ }exponents, subscripts or parentheses. For such constructs,
+or more exotic ones, the order-override option is always available. If
+it is present (even if empty), the algorithm is bypassed completely and
+one can include `anything' there without causing error.
+
+I doubt that these limitations matter in any practical sense. We are in
+`overkill' territory here. Mixed partial derivatives are used far more
+rarely than the `pure' ones, and mixed partial derivatives to `exotic'
+orders of differentiation are used \emph{vanishingly} rarely, and in any
+case the order-override option is always available. But should you, in
+some freak circumstance, find yourself needing to write such things, then
+I suggest you use \texttt{diffcoeffx.sty}, which is \texttt{diffcoeff.sty}
+`on steroids'. It can handle the situations described above that are
+beyond the scope of \texttt{diffcoeff.sty}, and it uses exactly the same
+commands so there is nothing new to remember. It also provides additonal
+functionality for the trailing optional argument.
+
+\subsubsection{Presentation of the overall order}
+
+To take a grotesque example, that will never arise in practice, consider
+the following: 
+\begin{example}
+\textbackslash{}diffp{[}kmn-mn+n-1,2kmn-mn+2n-1,n+1{]}\{f\}\{x,y,z,w\}
+$\Longrightarrow{\displaystyle \diffp[kmn-mn+n-1,2kmn-mn+2n-1,n+1]{f}{x,y,z,w}}.$
+\end{example}
+As noted earlier, since the final variable $w$ is differentiated only
+to order 1, there is no need to specify it in the comma list of orders.
+The implicit 1 contributes to the vanishing of the numerical part in the
+overall order of differentiation. In this example, the overall order contains
+multivariable terms, $kmn$ and $mn$. \texttt{diffcoeff} initially organises
+these in the sequence: \ldots{} 3-variable terms before 2-variable terms
+before single-variable terms, generally before the numerical term. However
+if a minus sign precedes the first many-variable term, and the numerical
+term is positive, it will be presented first:
+\begin{example}
+\textbackslash{}diffp{[}12-2km,k-1,km+1{]}\{f\}\{x,y,z,w\} $\Longrightarrow{\displaystyle \diffp[12-2km,km-1,k+1]{f}{x,y,z,w}}.$
+\end{example}
+Should the numerical term either vanish or be negative and the leading
+algebraic term is preceded by a minus sign, \texttt{diffcoeff} will look
+for an algebraic term with a preceding $+$ sign and put that first:
+\begin{example}
+\textbackslash{}diffp{[}2km-3k-1,2k-1,-3km+4k+1{]}\{f\}\{x,y,z,w\} $\Longrightarrow{\displaystyle \diffp[2km-3k-1,2k-1,-3km+4k+1]{f}{x,y,z,w}}.$
+\end{example}
+
+\subsection{\textbackslash{}diffset: formatting tweaks}
+
+As with ordinary derivatives, there are a number of tweaks one can make
+to the display of a partial derivative. 
+
+You may want more space between the $\partial$ symbol in the numerator
+of a partial derivative and the superscripted order of the derivative.
+The separation can be altered by using the 
+\begin{example}
+\textbackslash{}diffset{[}p-sep = $n${]}
+\end{example}
+\noindent command which adds an extra $n$~mu to \TeX{}'s spacing. The
+default value is 1 (i.e. 1~mu). The new separation will affect all derivatives
+following the new setting. Put in the preamble, the new separation will
+be document-wide.
+
+You may also want to adjust the spacing between the terms in the denominator.
+This can be done with the command
+\begin{example}
+\textbackslash{}diffset{[}sep=$n${]}
+\end{example}
+which adds an extra $n$~mu to \TeX{}'s spacing. The default value is
+2~mu.
+
+If you wish to indicate the point at which a partial derivative is evaluated,
+you may not want to use parentheses, since these when subscripted are widely
+held to indicate variables held constant. To change the delimiter on the
+right to a vertical line, use
+\begin{example}
+\textbackslash{}diffset{[}p-delims = . | {]}\textmd{,}
+\end{example}
+the dot suppressing the delimiter on the left. (Note that to use \texttt{\textbackslash{}\{}
+and \texttt{\textbackslash{}\}} as delimiters, \texttt{\textbackslash{}diffset
+}must be placed between maths delimiters.) 
+
+Changing the delimiters will usually require a repositioning of the subscript.
+The command is
+\begin{example}
+\textbackslash{}diffset{[}p-nudge = $n${]}\textmd{.}
+\end{example}
+For parentheses the default value of $n$ is $-6$, but for the vertical
+rule a zero value is appropriate. Thus the overall command for . | would
+be
+\begin{example}
+\textbackslash{}diffset{[}p-delims = . |, p-nudge = 0{]} \textmd{.}
+\end{example}
+Writing 
+\begin{example}
+\textbackslash{}diffset
+\end{example}
+will return all settings to their default values.
+
+\subsection{Variations}
+
+\subsubsection{Multi-character variables of differentiation}
+
+In thermodynamics one may want to differentiate in the reciprocal of the
+temperature, $1/T$. In tensor calculus the differentiations are almost
+always in terms of super- or subscripted coordinates, and in many other
+contexts this is the case too. This is why a comma list is used in \texttt{diffcoeff}
+for specifying the variables of differentiation for partial derivatives.
+Although it would be nice to write the minimal \texttt{\{xy\}} for this
+rather than \texttt{\{x,y}\}, the extra writing is trivial and the comma
+list allows the simplest handling of multi-character variables:
+\begin{example}
+\textbackslash{}diffp\{A\_i\}\{ x\textasciicircum{}j,x\textasciicircum{}k
+\} $\Longrightarrow{\displaystyle \diffp{A_{i}}{x^{j},x^{k}},}$
+\end{example}
+taken from tensor calculus, or this strange object taken from statistical
+mechanics:
+\begin{example}
+\textbackslash{}diffp{[}2{]}q\{\textbackslash{}frac 1\textbackslash{}Theta\}
+$\Longrightarrow{\displaystyle \diffp[2]q{\frac{1}{\Theta}}}$.
+\end{example}
+The parentheses have been inserted automatically by \texttt{diffcoeff}
+to clarify exactly what the variable of differentiation is.
+
+\subsubsection{Use of phantoms when appending differentiands}
+
+As for ordinary derivatives, when appending a differentiand you may want
+to include a phantom (\texttt{\textbackslash{}hphantom} etc.) in the numerator
+of the differential coefficient to alter the placement of the $\partial$
+symbol. This may be particularly relevant if the order of differentiation
+is a multi-character symbol or if there are a number of variables of differentiation. 
+
+Either means of achieving the appended differentiand achieve the same result:
+\begin{example}
+\textbackslash{}diffp{[}m,2{]}\{\textbackslash{}hphantom\{\textbackslash{}partial
+y \textbackslash{}partial \}\}\{x,y,z\} (\textbackslash{}ln \textbackslash{}cos
+x + \textbackslash{}ln \textbackslash{}sin y)z $\Longrightarrow\quad{\displaystyle \diffp[m,2]{\hphantom{\partial y\partial}}{x,y,z}}(\ln\cos x+\ln\sin y)z,$\medskip{}
+
+\textbackslash{}diffp{*}{[}m,2{]}\{\textbackslash{}hphantom\{\textbackslash{}partial
+y \textbackslash{}partial \}(\textbackslash{}ln \textbackslash{}cos x +
+\textbackslash{}ln \textbackslash{}sin y)z\}\{x,y,z\} $\Longrightarrow\quad{\displaystyle \diffp*[m,2]{\hphantom{\partial y\partial}(\ln\cos x+\ln\sin y)z}{x,y,z}},$
+\end{example}
+which is to be compared with the derivative without the phantom,
+\begin{example}
+\textbackslash{}diffp{*}{[}m,2{]}\{(\textbackslash{}ln \textbackslash{}cos
+x + \textbackslash{}ln \textbackslash{}sin y)z\}\{x,y,z\} $\Longrightarrow\quad{\displaystyle \diffp*[m,2]{(\ln\cos x+\ln\sin y)z}{x,y,z}}.$
+\end{example}
+\noindent In the starred form, \texttt{diffcoeff} understands that the
+phantom is not appended with the differentiand but stays in the numerator.
+(But a \emph{second} phantom would be appended.) 
+
+\subsubsection{Iterated derivatives}
+
+Partial derivatives can be iterated. For example,
+\begin{example}
+\textbackslash{}diffp f\{x,y\} = \textbackslash{}diffp{*}\{\textbackslash{}diffp
+fy\}x $\Longrightarrow{\displaystyle \diffp f{x,y}=\diffp*{\diffp fy}x,}$\medskip{}
+
+\textbackslash{}diffp f\{x,y\} = \textbackslash{}diffp\{\textbackslash{}diffp
+fy\}x $\Longrightarrow{\displaystyle \diffp f{x,y}=\diffp{\diffp fy}x.}$
+\end{example}
+It is easy to switch between these forms by inserting or deleting the asterisk.
+
+\subsection{Jacobians}
+
+\texttt{diffcoeff} provides a command \texttt{\textbackslash{}jacob} for
+constructing Jacobians. For example
+\begin{example}
+\textbackslash{}jacob\{u,v,w\}\{x,y,z\} $\Longrightarrow{\displaystyle \jacob{u,v,w}{x,y,z}.}$
+\end{example}
+The comma lists can contain any number of variables. \texttt{\textbackslash{}jacob}
+does \emph{not} check that the two arguments contain the same number of
+variables, so it is perfectly possible to form an object like
+\begin{example}
+\textbackslash{}jacob\{u,v,w\}\{x,y\} ,
+\end{example}
+which as far as I know has no meaning.
+
+\section{Discussion of the code}
+
+I set about creating this package when faced with trying to parse \LaTeX{}
+expressions involving derivatives for another program I was working on.
+Trying to parse \texttt{\textbackslash{}frac\{d<something>\}\{d<something
+else>\}}, perhaps with \texttt{\textbackslash{}mathrm\{d\}}'s, and a superscript
+on the first \texttt{d}, perhaps with a \texttt{\textbackslash{}tfrac}
+or \texttt{\textbackslash{}dfrac} for the \texttt{\textbackslash{}frac},\textbf{
+}wasn't quite hopeless, but it was certainly \emph{messy}. (I used regular
+expressions to transform the fraction into something more systematic.) 
+
+\subsection{Other packages}
+
+Looking through the MiK\TeX{} distribution and, less assiduously, through
+CTAN, produced the following packages which provide macros for derivatives.
+(Strangely, AMS packages do not touch this subject, as far as I can see.)
+\begin{itemize}
+\item \texttt{bropd}
+\begin{itemize}
+\item \texttt{\textbackslash{}od{[}n{]}\{y\}\{x\}} and \texttt{\textbackslash{}pd{[}n{]}\{y\}\{x\}}
+for ordinary and partial derivatives of order \texttt{n} in one variable
+\item \texttt{\textbackslash{}pd\{u\}\{x,x,t\}} for a mixed partial derivative,
+order 2 in \texttt{x}, 1 in \texttt{t}
+\item \texttt{\textbackslash{}pd\{\}\{z\}\{x+y\}} for appending \texttt{(x+y)}
+\item \texttt{\textbackslash{}pd\{!\}\{z\}\{x+y\}} for appending \texttt{x+y}
+\end{itemize}
+\item \texttt{commath}
+\begin{itemize}
+\item \texttt{\textbackslash{}od{[}n{]}\{y\}\{x\}} and \texttt{\textbackslash{}pd{[}n{]}\{y\}\{x\}}
+for ordinary and partial derivatives of order \texttt{n} in one variable
+\item \texttt{\textbackslash{}md\{f\}\{5\}\{x\}\{2\}\{y\}\{3\}} for a 5th order
+mixed partial derivative
+\item \texttt{\textbackslash{}tmd}, \texttt{\textbackslash{}dmd} and similar
+commands for forcing text and display styles
+\end{itemize}
+\item \texttt{esdiff}
+\begin{itemize}
+\item \texttt{\textbackslash{}diff{[}n{]}\{y\}\{x\}}\textbf{ }and \texttt{\textbackslash{}diffp{[}n{]}\{y\}\{x\}}\textbf{
+}for ordinary and partial derivatives of order \texttt{n} in one variable
+\item \texttt{\textbackslash{}diffp\{f\}\{\{x\textasciicircum{}2\}\{y\}\{z\textasciicircum{}3\}\}}
+for a mixed partial derivative of order 6 in three variables
+\item \texttt{\textbackslash{}diff{*}{[}n{]}\{y\}\{x\}\{0\}} for indicating the
+point of evaluation of the derivative (using a subscript on parentheses)
+\item \texttt{\textbackslash{}diffp{*}\{P\}\{T\}\{V\}} to indicate a variable
+held constant
+\end{itemize}
+\item \texttt{physymb}
+\begin{itemize}
+\item \texttt{\textbackslash{}ud\{y\}\{x\}} and \texttt{\textbackslash{}pd\{y\}\{x\}}
+for ordinary and partial derivatives of first order
+\item \texttt{\textbackslash{}udd\{y\}\{x\}}, \texttt{\textbackslash{}uddd\{y\}\{x\}}
+and \texttt{\textbackslash{}pdd\{y\}\{x\}}, \texttt{\textbackslash{}pddd\{y\}\{x\}}
+for second and third order ordinary and partial derivatives
+\item higher order derivatives not catered for
+\end{itemize}
+\end{itemize}
+None of the packages quite gave what I wanted (but for all that, I suspect
+cope with well over 90\% of use cases). \texttt{esdiff} comes closest but
+failed when it came to combining algebraic and numeric orders of differentation
+in a mixed partial derivative. Also the need to em-brace variables in a
+mixed partial derivative in \texttt{esdiff}\textbf{ }was another (small)
+count against it. 
+
+\subsection{diffcoeff.sty}
+\begin{itemize}
+\item The distinctive feature of \texttt{diffcoeff.sty} is that it will automatically
+form the overall order of a mixed partial derivative, including those containing
+both algebraic and numeric contributions to the order:
+\end{itemize}
+\begin{example}
+\textbackslash{}diffp{[}m-k-1,m+k{]}\{F(x,y,z)\}\{x,y,z\} $\Longrightarrow{\displaystyle \diffp[m-k-1,m+k]{F(x,y,z)}{x,y,z}}.$
+\end{example}
+\begin{itemize}
+\item Ease of use was another major consideration, trying to avoid the unnecessary
+writing of superscripts and subscripts and brace pairs. In this example,
+no superscripts are written and only the two inescapable brace pairs are
+required. 
+\begin{itemize}
+\item The use of a comma list for the second mandatory argument in a partial
+derivative is another example. That makes differentiations in super- or
+subscripted symbols easier to both write and read by avoiding `entanglements'
+of braces.
+\end{itemize}
+\item I've also tried to make the options `natural' and consistent across both
+ordinary and partial derivatives. Looking at the other packages listed
+above, writing something like \texttt{\textbackslash{}diff{[}n{]}\{f\}\{x\}}
+(which can be trimmed to \texttt{\textbackslash{}diff{[}n{]}fx} in this
+instance) seems `natural' \textendash{} only \texttt{physymb} deviates
+from the pattern. It seems consistent with this pattern to use a comma
+list as an optional argument for mixed partial derivatives. 
+\item I debated whether to include provision for points of evaluation and variables
+held constant into the \texttt{\textbackslash{}diff} and \texttt{\textbackslash{}diffp}
+commands. \texttt{esdiff} certainly allows this. I think a case can be
+made, in subjects like thermodynamics, to consider the parentheses and
+subscript as part of the overall symbol. The partial derivative itself
+doesn't give the full story; it is ambiguous. Hence provision for these
+extra elements was included in \texttt{\textbackslash{}diff} and \texttt{\textbackslash{}diffp}.
+It's positioning as a final optional argument also felt natural given the
+position of the resulting symbol in the displayed derivative:
+\end{itemize}
+\begin{example}
+\textbackslash{}diffp ST\{V\} $\Longrightarrow\quad{\displaystyle \diffp ST{V}}$
+\end{example}
+\begin{itemize}
+\item Although initially I used standard square brackets for this trailing optional
+argument, the possibility of an immediately following mathematical expression
+being enclosed in square brackets convinced me to use braces for the argument.
+An immediately following expression can now be enclosed in \texttt{{[}
+{]}}, or \texttt{\textbackslash{}\{ \textbackslash{}\}}, without ambiguity.
+\item The star option also prompted the reflection: is it needed? One can always
+leave the first mandatory argument empty and append the differentiand `by
+hand'. But once the provision for points of evaluation or variables held
+constant was incorporated into the \texttt{\textbackslash{}diff} and \texttt{\textbackslash{}diffp}
+commands, the star option became the simplest way of handling appended
+differentiands using the extra provision. (Note that it conflicts with
+the star option in \texttt{esdiff}, but I can't see the packages ever being
+used together.) And once the option is available, it provides a simple
+way to switch between differentiand in the numerator/differentiand appended.
+\item The final option added to the package was the slash option. This was prompted
+after seeing the expression $\diff*{[\log f(z)]}/z$ in a text on statistical
+mechanics. Alerted to the form, I then skimmed through various texts and
+found this form of the derivative was used sufficiently often to justify
+inclusion. The placement of the slash, between the two mandatory arguments,
+seemed more-or-less self-evident.
+\end{itemize}
+
+\subsection{The mixed partial derivatives algorithm}
+
+It occurred to me, after I had created an algorithm for splitting a linear
+expression composed of signs, integers and variables into its numerical
+and algebraic parts, that the same algorithm could be used in a recursive
+way to simplify the algebraic part of the expression.
+
+Given an order specification like, say, \textbf{\strong{\textbf{{[}2m+k\textendash 1,2m\textendash k+1,2k,1{]}}}},
+the idea is to concatenate the terms with intervening \textbf{+} signs,
+thus \textbf{\strong{\textbf{2m+k\textendash 1+2m\textendash k+1+ 2k+1}}},
+then split this expression into numeric and algebraic parts, giving \textbf{\strong{\textbf{\textendash 1+ 1+1}}}
+for the numeric part and \textbf{\strong{\textbf{2m+k+2m\textendash k+2k}}}
+for the algebraic part. The numeric part, assumed to be a combination of
+integers, is evaluated and the result stored. For the algebraic part, remove
+throughout all instances of one of the variables, say \textbf{\strong{\textbf{m}}}.
+The result is \textbf{\strong{\textbf{2+k+2\textendash k+2k}}}. Split
+this into numeric and algebraic parts: \textbf{\strong{\textbf{2+2}}}
+for the numeric part and \textbf{\strong{\textbf{k\textendash k+2k}}}
+for the algebraic part. Evaluate the numeric part, \textbf{\strong{\textbf{+4}}},
+and you have the overall coefficient of the variable \textbf{\strong{\textbf{m}}}.
+Repeat the process for the next variable, and so on until all variables
+have been accounted for. 
+
+In fact repeating the process for the next variable, \strong{k} in this
+example, immediately reveals a problem. Removing \strong{k} from \textbf{\strong{\textbf{k\textendash k+2k}}}
+leaves \strong{\textendash +2} which evaluates to \strong{\textendash 2}
+whereas the correct coefficient for \strong{k} should be \strong{+2}.
+The solution is to insert \strong{1} before any `bare' variable \textendash{}
+a variable preceded only by a sign rather than a number. In that case the
+expression we remove \strong{k} from is \strong{1k\textendash 1k+2k}
+giving the correct overall coefficient \strong{+2}.
+
+A second problem may arise if there are terms involving products of variables
+as in the order specification \strong{{[}mk\textendash 2,2m+1,2k+1{]}}.
+This splits into a numeric part \strong{\textendash 2+1+1} evaluating
+to \strong{0}, and an algebraic part \strong{mk+2m+2k}. If we choose
+\strong{m} as the first variable to remove from this expression, we get
+\strong{+2} for the numeric part (and hence the overall coefficient of
+\strong{m}) and \strong{k+2k} for the algebraic part, which is wrong,
+since that will lead to the wrong overall coefficient \strong{+3} for
+\strong{k}, and the 2-variable term \strong{mk} will not get treated
+at all. The cure is to treat \strong{mk} as a variable itself, count the
+number of tokens in each such product and start the removal process with
+the largest.
+
+\subsubsection{The splitting algorithm}
+
+Write $s$ for a sign, one of \strong{+}, \strong{\textendash{}}, and
+\strong{s} for the state of assembling a signed term; a signed term is
+a string of one or more signs. Write $d$ for a digit, one of 0123456789,
+and \strong{n} for the state of assembling a numeric term; a numeric term
+is a signed term followed by a string of one or more digits. Write $v$
+for a variable, usually a letter from the roman alphabet but in principle
+any single token that is not a sign or a digit, and \strong{a} for the
+state of assembling an algebraic term; an algebraic term is a numeric term
+followed by a string of one or more variables. Rather than referring to
+a signed-term-assembling state, we shall (obviously) simply refer to a
+\emph{signed state}, and similarly to a \emph{numeric state} and an \emph{algebraic
+state}.
+
+\begin{table}
+\noindent \centering{}\caption{\label{tab:Input-output-states}State transitions}
+\medskip{}
+\begin{tabular}{ccccc}
+\cmidrule{2-5} 
+ & Curr. state & Curr. token & Action & Next state\tabularnewline
+\cmidrule{2-5} 
+1 & \strong{s} & $s$ & $Ts\to s'$; $T=s'$ & \strong{s}\tabularnewline
+\cmidrule{2-5} 
+2 & \strong{s} & $d$ & $Td$ & \strong{n}\tabularnewline
+\cmidrule{2-5} 
+3 & \strong{s} & $v$ & $Vv$; $T1v$ & \strong{a}\tabularnewline
+\cmidrule{2-5} 
+4 & \strong{n} & $s$ & $\mathbf{N}T$; $T=s$ & \strong{s}\tabularnewline
+\cmidrule{2-5} 
+5 & \strong{n} & $d$ & $Td$ & \strong{n}\tabularnewline
+\cmidrule{2-5} 
+6 & \strong{n} & $v$ & $Vv$; $Tv$ & \strong{a}\tabularnewline
+\cmidrule{2-5} 
+7 & \strong{a} & $s$ & $\mathbf{V}V,$; $V=\textrm{\xD8}$; $\mathbf{A}T$; $T=s$ & \strong{s}\tabularnewline
+\cmidrule{2-5} 
+8 & \strong{a} & $d$ & error & \strong{!!}\tabularnewline
+\cmidrule{2-5} 
+9 & \strong{a} & $v$ & $Vv$; $Tv$ & \strong{a}\tabularnewline
+\cmidrule{2-5} 
+\end{tabular}
+\end{table}
+We also want to record the variables in the extended sense of products
+of same. Call a one-token variable a prime variable. Then in this desired
+sense, a variable is a string of one or more prime variables. 
+
+Let $\mathbf{E}$ be the initial expression. Let $\mathbf{A}$ be a container
+for the algebraic part of $\mathbf{E}$; let $\mathbf{N}$ be a container
+for the numeric part of $\mathbf{E}$; and let $\mathbf{V}$ be a container
+for the extended variables in $\mathbf{E}$. Let $T$ be a container in
+which to accumulate the current term, and $V$ a container in which to
+accumulate the current extended variable (if any). Initially all these
+containers are empty ($\textrm{\xD8}$).
+
+We work through $\mathbf{E}$ token by token from the left. The table shows
+the alternatives. 
+\begin{itemize}
+\item Row 1. The current token is a sign $s$ and the system is in a signed state
+\strong{s}. We append $s$ to the current term, $Ts$, then resolve the
+juxtaposition of signs according to the familiar rules: $++\to+$, $--\to+$,
+$+-\to-$, $-+\to-$, so that $T$ contains only the resolved sign $s'$.
+The system remains in a signed state.
+\item Row 2. The current token is a digit $d$ and the system is in a signed-
+state \strong{s}. We append $d$ to the current term, $Td$ (which will
+now consist of a sign and a digit), and the system shifts to a numeric
+state \strong{n}.
+\item Row 3. The current token is a prime variable $v$ and the system is in
+a signed state \strong{s}. We start assembling an extended  variable,
+$Vv$, and append $1v$ to the current term, $T1v$, where the $1$ is
+necessary as discussed earlier (and in any case `sign variable' is not
+a recognised \emph{term} \textendash{} neither signed, numeric or algebraic).
+The system shifts to an algebraic state \strong{a}.
+\item Row 4. The current token is a sign $s$ and the system is in a numeric
+state \strong{n}. The current term is a numeric term, a sign followed
+by at least one digit, and is complete. We append it to the numeric part
+$\mathbf{N}$ of $\mathbf{E}$, $\mathbf{N}T$, then initialise $T$ to
+$s$. The system shifts to a signed state.
+\item Row 5. The current token is a digit $d$ and the system is in a numeric
+state \strong{n}. We append $d$ to the current term, $Td$, and remain
+in a numeric state.
+\item Row 6. The current token is a prime variable $v$ and the system is in
+a numeric state \strong{n}. We start assembling a  variable, $Vv$, and
+also append $v$ to the current term, $Tv$. The system shifts to an algebraic
+state \strong{a}.
+\item Row 7. The current token is a sign $s$ and the system is in an algebraic
+state \strong{a}. The current term is an algebraic term, a sign followed
+by at least one digit followed by at least one prime variable, and is complete.
+We append it to the algebraic part $\mathbf{A}$ of $\mathbf{E}$, $\mathbf{A}T$,
+then initialise $T$ to $s$. We also append $V$, in which we have been
+accumulating the (extended) variable, to $\mathbf{V}$, $\mathbf{V}V,$,
+then empty $V$ in preparation for the next (extended) variable. Attention
+is drawn to the comma following $V$ also appended to $\mathbf{V}$, so
+that we can distinguish where one variable ends and the next begins. The
+system shifts to a signed state.
+\item Row 8. The current token is a digit $d$ and the system is in an algebraic
+state \strong{a}. This situation should not arise.\emph{ }We don't write
+$k2$; we write $2k$ \textendash{} number precedes variable. An error
+is generated. 
+\item Row 9. The current token is a variable $v$ and the system is in an algebraic
+state \strong{a}. We append $v$ to the current extended  variable, $Vv$,
+and also append $v$ to the current term, $Tv$. The system remains in
+an algebraic state \strong{a}.
+\end{itemize}
+To get things under way, an initial plus sign is put in $T$, $T=+$, and
+the system is set to the signed state \strong{s}. In order that \emph{all}
+terms of $\mathbf{E}$ are recorded in either $\mathbf{N}$ or $\mathbf{A}$,
+and all extended variables in $\mathbf{V}$, we append a plus sign to $\mathbf{E}$:
+$\mathbf{E}+$. Since an expression doesn't end with a trailing sign (we
+don't write, e.g., \textbf{\strong{\textbf{2m+k\textendash{}}}}), the
+process necessarily terminates either in row 4 or row 7 with the final
+term appended either to $\mathbf{N}$ or $\mathbf{A}$ and with $T=+$;
+if it terminates in row 7, the final extended variable is appended to $\mathbf{V}$,
+$\mathbf{V}V$ (and $V$ is emptied, although that hardly matters at this
+point).
+
+\subsubsection{An enlarged scheme?}
+
+Row 8 of our table generates an error: a digit following a variable. But
+having allowed products of variables like \texttt{mn} ($mn$), it is very
+tempting to allow \texttt{mm}, i.e. \texttt{m\textasciicircum{}2} ($m^{2}$)
+and, indeed, \texttt{m\textasciicircum{}n} ($m^{n}$). And if we allow
+\texttt{m\textasciicircum{}2} and \texttt{m\textasciicircum{}n}, how can
+we say no to subscripted forms like \texttt{k\_2} ($k_{2}$) and \texttt{k\_n}
+($k_{n}$)? Or, for that matter, \texttt{k\_+} ($k_{+}$) and \texttt{k\_-}
+($k_{-}$), and therefore \texttt{m\textasciicircum{}+} ($m^{+}$) and
+\texttt{m\textasciicircum{}-} ($m^{-}$)? And having extended the scheme
+in this way to exponents of \emph{variables}, surely it should also encompass
+exponents of \emph{numbers}, not only an obvious case like \texttt{2\textasciicircum{}2}
+($2^{2}$) but less obviously, yet still compellingly, \texttt{2\textasciicircum{}n}
+($2^{n}$)? 
+
+Each of these extensions produces its own problems, but they can all be
+accommodated within an enlarged scheme, as can the use of parentheses (with
+numerical coefficients). Table~\ref{tab:Input-output-states} translates
+neatly into code. Rather than add these complications to \texttt{diffcoeff.sty},
+I have transferred the enlarged scheme to \texttt{diffcoeff.sty}'s `big
+brother', \texttt{diffcoeffx.sty}. The comparable table and routine resulting
+from it in \texttt{diffcoeffx.sty} is much bigger and less obvious than
+in \texttt{diffcoeff.sty}.
+
+\subsubsection{Some code details}
+
+In the code, the states are distinguished by integers as indicated in Table~\ref{tab:State-integers}.
+Tokens are assigned similar integer indexes, as indicated in the table.
+The relevant routine is \texttt{\textbackslash{}\_\_diffco\_get\_curr\_index:NN}.
+The actions embodied in Table~\ref{tab:Input-output-states} are encoded
+in \texttt{\textbackslash{}\_\_diffco\_compare\_states:NNNNN} which is
+a direct translation of the table into expl3 code.
+
+\begin{table}[h]
+\caption{Some code details}
+
+\noindent \centering{}\subfloat[\label{tab:State-integers}State integers]{\centering{}%
+\begin{tabular}{|c|c|c|}
+\hline 
+State & Index & Tokens\tabularnewline
+\hline 
+\hline 
+signed & 0 & $+$ $-$\tabularnewline
+\hline 
+numeric & 1 & 0123456789\tabularnewline
+\hline 
+algebraic & 2 & variables\tabularnewline
+\hline 
+\end{tabular}}~~~\subfloat[Translations]{
+\centering{}%
+\begin{tabular}{|c|c|}
+\hline 
+Symbol & Code variable\tabularnewline
+\hline 
+\hline 
+$s$,$d$,$v$ & \texttt{\textbackslash{}l\_\_diffco\_curr\_tok\_tl}\tabularnewline
+\hline 
+$T$ & \texttt{\textbackslash{}l\_\_diffco\_curr\_term\_tl}\tabularnewline
+\hline 
+$V$ & \texttt{\textbackslash{}l\_\_diffco\_curr\_var\_tl}\tabularnewline
+\hline 
+$\mathbf{N}$ & \texttt{\textbackslash{}l\_\_diffco\_nos\_tl}\tabularnewline
+\hline 
+$\mathbf{A}$ & \texttt{\textbackslash{}l\_\_diffco\_alg\_tl}\tabularnewline
+\hline 
+$\mathbf{V}$ & \texttt{\textbackslash{}l\_\_diffco\_vars\_prop}\tabularnewline
+\hline 
+\end{tabular}}
+\end{table}
+A property list is used to store the variables, organised by size \textendash{}
+the number of tokens composing an extended variable. This enables the sorting
+by size needed for the determination of the overall coefficients of variables
+by removing them in turn from the algebraic part of the expression. That
+process is conducted in the routine \texttt{\textbackslash{}\_\_diffco\_eval\_vars:NN}.
+The variables are recorded only on the first scan through the order specification
+expression. This is the function of the boolean \texttt{\textbackslash{}l\_\_diffco\_vars\_noted\_bool}
+which is set in \texttt{\textbackslash{}\_\_diffco\_eval\_vars:NN}. Evaluation
+of the numeric parts of expressions is provided by \texttt{\textbackslash{}\_\_diffco\_eval\_nos:N}.
+
+\section{Summary of main commands}
+
+\subsubsection{Ordinary derivatives}
+
+The syntax is
+\begin{example}
+{\small{}\textbackslash{}diff{[}order{]}\{differentiand\}\{variable\}\{point
+of evaluation\}}{\small \par}
+\end{example}
+for the differentiand in the numerator, and where the final argument, although
+using braces, is an \emph{optional} argument. A starred form appends the
+differentiand:
+\begin{example}
+{\small{}\textbackslash{}diff{*}{[}order{]}\{differentiand\}\{variable\}\{point
+of evaluation\}}{\small \par}
+\end{example}
+No space must occur between the final optional argument, if it is used,
+and the second mandatory argument. 
+
+There are also slash forms of both these commands:
+\begin{example}
+{\small{}\textbackslash{}diff{[}order{]}\{differentiand\}/\{variable\}\{point
+of evaluation\}}{\small \par}
+
+{\small{}\textbackslash{}diff{*}{[}order{]}\{differentiand\}/\{variable\}\{point
+of evaluation\}}{\small \par}
+\end{example}
+For the starred form, the differential coefficient is enclosed in parentheses.
+
+Precisely similar definitions, but without the slash forms, apply to \texttt{\textbackslash{}Diff},
+forming a differential coefficient with $D$, \texttt{\textbackslash{}diffd},
+forming a differential coefficient with $\delta$, and \texttt{\textbackslash{}Diffd},
+forming a differential coefficient with $\Delta$.
+
+\subsubsection{Partial derivatives}
+
+The syntax is
+\begin{example}
+{\small{}\textbackslash{}diffp{[}order spec.{]}{[}order override{]}\{differentiand\}\{variables\}\{constant
+variables\}}{\small \par}
+\end{example}
+for the differentiand in the numerator and where the final argument, although
+in braces, is an \emph{optional} argument. No space must occur between
+the final optional argument, if it is used, and the second mandatory argument.
+The \textbf{\strong{\textbf{order spec.}}} is a comma-separated list;
+the \strong{variables} is also a comma-separated list. A starred form
+appends the differentiand:
+\begin{example}
+{\small{}\textbackslash{}diffp{*}{[}order{]}{[}order~override{]}\{differentiand\}\{variables\}\{constant
+variables\}}{\small \par}
+\end{example}
+Slash forms exist also for these commands:
+\begin{example}
+{\small{}\textbackslash{}diffp{[}order spec.{]}{[}order override{]}\{differentiand\}/\{variables\}\{constant
+variables\}}{\small \par}
+
+{\small{}\textbackslash{}diffp{*}{[}order{]}{[}order~override{]}\{differentiand\}/\{variables\}\{constant
+variables\}}{\small \par}
+\end{example}
+For the starred version of the slash form, the differential coefficient
+is enclosed in parentheses.
+
+\subsubsection{Settings}
+\begin{example}
+\textbackslash{}diffset{[}option1=<value1>,option2=<value2>,...{]}
+\end{example}
+All numerical values should be integers (\texttt{diffcoeff} interprets
+this in units of mu, 1/18 of an em). To return all options to default values,
+write
+\begin{example}
+\textbackslash{}diffset
+\end{example}
+The options and defaults are
+\begin{description}
+\item [{\strong{roman = false}}] \textbf{\strong{\textbf{true}}} gives upright
+(roman) \textbf{\strong{\textbf{d}}} and \textbf{\strong{\textbf{D}}} 
+\item [{\strong{d-delims = . |}}] delimiters which, when subscripted, indicate
+the point of evaluation of an ordinary derivative
+\item [{\strong{p-delims = ( )}}] delimiters which, when subscripted, indicate
+variables held constant for partial derivatives
+\item [{\strong{d-nudge = 0}}] adjustment for positioning the subscript to
+the preceding delimiters
+\item [{\strong{p-nudge = $-$6}}] adjustment for positioning the subscript
+to the preceding delimiters
+\item [{\strong{d-sep = 1}}] additional separation between the \textbf{$d$
+}and its superscript in the numerator of a second or higher order ordinary
+derivative
+\item [{\strong{p-sep = 1}}] additional separation between the \textbf{$\partial$}
+and its superscript in the numerator of a second or higher order partial
+derivative
+\item [{\strong{sep = 2}}] additional separation between the terms in the denominator
+of a mixed partial derivative
+\end{description}
+
+\end{document}


Property changes on: trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeff.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeffx.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeffx.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeffx.pdf	2016-06-27 20:40:03 UTC (rev 41553)
+++ trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeffx.pdf	2016-06-27 20:41:31 UTC (rev 41554)

Property changes on: trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeffx.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeffx.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeffx.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeffx.tex	2016-06-27 20:41:31 UTC (rev 41554)
@@ -0,0 +1,656 @@
+%% LyX 2.2.0 created this file.  For more info, see http://www.lyx.org/.
+%% Do not edit unless you really know what you are doing.
+\documentclass[twoside,english]{article}
+\usepackage{lmodern}
+\renewcommand{\sfdefault}{lmss}
+\renewcommand{\ttdefault}{lmtt}
+\usepackage[T1]{fontenc}
+\usepackage[latin9]{inputenc}
+\usepackage{geometry}
+\geometry{verbose,lmargin=4cm,rmargin=3.5cm}
+\setcounter{secnumdepth}{2}
+\setcounter{tocdepth}{1}
+\usepackage{wrapfig}
+\usepackage{booktabs}
+\usepackage{amstext}
+\usepackage{esint}
+
+\makeatletter
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
+%% Because html converters don't know tabularnewline
+\providecommand{\tabularnewline}{\\}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
+ \newenvironment{example}{\begin{center}\ttfamily}{\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}}
+\newcommand{\strong}[1]{\textbf{#1}}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
+\usepackage{diffcoeffx}
+
+\@ifundefined{showcaptionsetup}{}{%
+ \PassOptionsToPackage{caption=false}{subfig}}
+\usepackage{subfig}
+\makeatother
+
+\usepackage{babel}
+\begin{document}
+
+\title{\texttt{diffcoeffx}~\\
+extending the \texttt{diffcoeff} package}
+
+\author{Andrew Parsloe\\
+{\small{}(aparsloe at clear.net.nz)}}
+\maketitle
+\begin{abstract}
+\noindent \texttt{diffcoeffx.sty} is \texttt{diffcoeff.sty} `on steroids'.
+It provides additional functionality for the trailing optional argument
+and extends the algorithm used to calculate the overall order of differentiation
+of mixed partial derivatives. That now accepts order-of-differentiation
+specifications that include powers of numbers and variables, subscripts
+on variables, and (possibly nested) parentheses with numerical coefficients.
+The enhancements come under the category of `gilding the lily'. 
+\end{abstract}
+
+\section{The \texttt{diffcoeffx} package}
+
+The \texttt{diffcoeffx} package is \texttt{diffcoeff} `on steroids',
+providing exactly the same commands but with some extra functionality.\texttt{ }It
+is called in the usual way in the LaTeX preamble:
+\begin{lyxcode}
+\textbackslash{}usepackage\{diffcoeffx\}
+\end{lyxcode}
+It is assumed that you are familiar with the \texttt{diffcoeff} package
+and its manual.\texttt{ }There are two enhancements to that package: \texttt{diffcoeffx}
+takes the calculation of the overall order of mixed partial derivatives
+deep into `overkill' territory, accepting single-token powers of numbers
+and variables, single-token subscripts on variables, and possibly nested
+parentheses with numerical coefficients. The \texttt{\textbackslash{}times}
+token ($\times$) can also be used in an order specification. The other
+enhancement is an extension to the capabilities of the trailing optional
+argument. 
+
+\subsection[Exploiting the final argument]{Exploiting the trailing optional argument}
+
+For \texttt{diffcoeff }there was an attempt to give a `natural feel'
+to the design choices made and their use. By comparison the additional
+functionality that the trailing optional argument acquires in \texttt{diffcoeffx.sty}
+is in the nature of a \emph{hack}. It works, but I'm not sure that it should
+be encouraged. 
+
+In \texttt{diffcoeff} if you write \texttt{\textbackslash{}diff yx\{\}}
+the trailing but \emph{empty} optional argument is ignored. Not so in \texttt{diffcoeffx}:
+\begin{example}
+\textbackslash{}diffp yx\{\}${\displaystyle \Longrightarrow\quad\diffp yx{}}$
+\end{example}
+The parentheses are inserted without a subscript. Thus we can write (for
+instance) Lagrange's equations of motion in analytical mechanics in the
+manner:
+\begin{example}
+\textbackslash{}diffp L\{q\_k\}-\textbackslash{}diff{*}\{\textbackslash{}diffp
+L\{\textbackslash{}dot\{q\}\_k\}\{\}\}t = 0 $\Longrightarrow\quad{\displaystyle \diffp L{q_{k}}-\diff*{\diffp L{\dot{q}_{k}}{}}t}=0$,
+\end{example}
+without having to bother with inserting \texttt{\textbackslash{}left(}
+and \texttt{\textbackslash{}right}).\texttt{ }The empty trailing optional
+argument and the default delimiters for partial derivatives do the job
+for us. 
+
+There are many other places in analytical mechanics where using an empty
+trailing optional argument is a similarly convenient way of writing large
+parentheses, for instance, 
+\begin{example}
+\textbackslash{}dot\{q\_k\}=\textbackslash{}diffp H\{\textbackslash{}diffp
+S\{q\_k\}\{\}\} ${\displaystyle \Longrightarrow\quad\dot{q_{k}}=\diffp H{\diffp S{q_{k}}{}}}\!.$ 
+\end{example}
+An application of Lagrange's equations (to a one-dimensional elastic solid)
+gives rise to a Langrangian density function,
+\begin{example}
+\textbackslash{}frac 12\textbackslash{}left\textbackslash{}\{ \textbackslash{}rho\textbackslash{}dot\{\textbackslash{}eta\}\textasciicircum{}2-E\textbackslash{}diff\textbackslash{}eta
+x\{;2;()\}\textbackslash{}right \textbackslash{}\} $\Longrightarrow\quad{\displaystyle \frac{1}{2}\left\{ \rho\dot{\eta}^{2}-E\diff\eta x{;2;()}\right\} }.$
+\end{example}
+Another application of those equations (the acoustic approximation to the
+irrotational motion of a compressible non-viscous fluid) produces a Lagrangian
+density
+\begin{example}
+\textbackslash{}frac 12\textbackslash{}rho\textbackslash{}left\textbackslash{}\{(\textbackslash{}nabla\textbackslash{}psi)\textasciicircum{}2-\textbackslash{}frac
+1\{c\textasciicircum{}2\}\textbackslash{}diff\textbackslash{}psi t\{;2;()\}\textbackslash{}right\textbackslash{}\}
+$\Longrightarrow\quad{\displaystyle \frac{1}{2}\rho\left\{ (\nabla\psi)^{2}-\frac{1}{c^{2}}\diff\psi t{;2;()}\right\} }.$
+\end{example}
+In both examples, the trailing optional argument of the \emph{ordinary}
+derivative has been filled by a semicolon-delimited list: \texttt{\{;2;()\}}.
+The initial slot where a subscript is specified is empty but the semicolon
+is necessarily included. The second spot specifies a \emph{superscript}
+and the third slot the delimiters to use. Since parentheses are not the
+default delimiters for an ordinary derivative we needed to specify them
+explicitly here. However, this does not change the default delimiters which
+remain \texttt{.|} for an ordinary derivative and can only be changed by
+means of the \texttt{\textbackslash{}diffset} command.
+
+Both subscript and superscript can be used at the same time. In a text
+on ordinary differential equations, an example employing Green's functions
+gives rise to
+\begin{example}
+\textbackslash{}diff{[}n-1{]}Gx\{\textbackslash{}xi-\textbackslash{}epsilon;\textbackslash{}xi+\textbackslash{}epsilon;{[}{]}\}
+$\Longrightarrow\quad{\displaystyle \diff[n-1]Gx{\xi-\epsilon;\xi+\epsilon;[]}}$
+\end{example}
+the derivative being evaluated at both superscript and subscript values
+and the difference taken. Here the trailing optional argument has its first
+three slots filled, with square brackets explicitly specified. The same
+book includes the example
+\begin{example}
+\textbackslash{}diff{*}{[}p-1{]}\{x\textasciicircum{}\textbackslash{}alpha\}\textbackslash{}alpha\{\textbackslash{}alpha=a;;\textbackslash{}\{\textbackslash{}\}\}
+$\Longrightarrow\quad{\displaystyle \diff*[p-1]{x^{\alpha}}\alpha{\alpha=a;;\{\}}}$
+\end{example}
+where, this time braces are specified in the trailing optional argument.\footnote{For LyX users, the braces \textbackslash{}\{ and \textbackslash{}\} are
+inserted into a formula in the maths editor simply by typing the braces
+without the backslashes. LyX takes care of the latter.} 
+
+This argument can be used to form the absolute value of a derivative,
+\begin{example}
+\textbackslash{}diff yx\{;;||\} ${\displaystyle \Longrightarrow\quad\diff yx{;;||}}$ 
+\end{example}
+where both initial slots, subscript and superscript, are empty and two
+semicolons necessarily included in the trailing optional argument: \texttt{\{;;||\}}.
+It also provides an alternative way, indeed \emph{two} alternative ways,
+of forming a quotient of derivatives:
+\begin{example}
+\textbackslash{}diff yx\{;;./\}\textbackslash{}diff xy=\textbackslash{}diff
+yx\textbackslash{}diff xy\{;;/.\} ${\displaystyle {\displaystyle \Longrightarrow\quad\diff yx{;;./}}\diff xy={\displaystyle \diff yx}\diff xy{;;/.}}$
+\end{example}
+where the delimiter specification \texttt{./} on the left has been changed
+to \texttt{/.} on the right. The spacing in the two quotients is not quite
+identical, which might be relevant in some contexts. As a more realistic
+example of use of the same construct, if $F(x,t)$ is a function of $x$
+and $t$ and $x=x(t)$, then if $\diff Ft=0$,
+\begin{example}
+\textbackslash{}diff xt=-\textbackslash{}diffp Ft\{;;./\}\textbackslash{}diffp
+Fx $\Longrightarrow\quad{\displaystyle \diff xt=-\diffp Ft{;;./}\diffp Fx}$
+\end{example}
+For an inline use, you may prefer to use the slash form of the derivative
+$\diff y/z{0;;();-1}$. In this case a \emph{fourth} slot in the trailing
+optional argument has been filled, the \texttt{nudge override} slot, since
+the default nudge is designed to position the subscript relative to the
+\emph{displaystyle} delimiters.
+
+The complete specification of what is available in the trailing optional
+argument is:
+\begin{example}
+\{ subscript; superscript; delimiters; nudge override \}
+\end{example}
+\begin{itemize}
+\item In `normal' use, the \texttt{subscript} is the point of evaluation (ordinary
+derivatives), or list of variables held constant (partial derivatives).
+Since the list of variables held constant is likely to be comma-separated,
+so we have the need for semicolons to separate items in the larger list. 
+\item The \texttt{superscript} is generally a power to which the derivative is
+raised but, as instanced by the Green's function example, it can also be
+another point of evaluation of the derivative.
+\item The \texttt{delimiters} are, by default, \texttt{.|} for ordinary derivatives
+and \texttt{()} for partial derivatives. These are not always the right
+ones for a particular task. Rather than changing them \emph{globally} as
+the use of \texttt{\textbackslash{}diffset} entails, they can be changed
+\emph{locally} for the particular instance by specifying them in this slot.
+The global choices are unaffected. 
+\item If the built-in placement of sub- or superscript relative to the right
+delimiter is unsatisfactory, a value specified in the \texttt{nudge override}
+slot\texttt{ }overrides the default value locally. The value is a pure
+number which \texttt{diffcoeffx} treats as that number of mu (1/18 of an
+em). (For comparison, a thin space \textbackslash{}, and a negative thin
+space \textbackslash{}! are 3/18 of an em.) The default nudges are shown
+in Table~\ref{tab:Default-nudges}. They are intended for displaystyle
+presentation, and are not affected by any value included in this slot.
+\end{itemize}
+\noindent\begin{minipage}[t]{1\columnwidth}%
+\begin{wraptable}[10]{o}{0.35\columnwidth}%
+\centering{}\caption{\label{tab:Default-nudges}Default nudges}
+\begin{tabular}{|c|c|}
+\hline 
+right delimiter & nudge\tabularnewline
+\hline 
+\hline 
+), > & -6\tabularnewline
+\hline 
+\textbackslash{}\} & -4\tabularnewline
+\hline 
+|, {]} & 0\tabularnewline
+\hline 
+other & 0\tabularnewline
+\hline 
+\end{tabular}\end{wraptable}%
+Note that if one wants to use the nudge override with the default delimiters,
+it is necessary to indicate all preceding slots, even if they are empty,
+e.g., \texttt{\{;;;-3\}}. Similarly, to change the delimiters, to parentheses
+say, without sub- or superscript, it is necessary to indicate all preceding
+empty slots, but the following one does not need to be indicated: \texttt{\{;;()\}}.
+If one wants to specify a superscript, 2 say, but leave all else unchanged,
+it is only necessary to specify the one preceding empty slot: \texttt{\{;2\}}.
+Trailing empty slots can be omitted, which is why, if one wants to use
+the trailing empty argument `as nature intended', i.e., to specify a
+point of evaluation or variables held constant, one can close one's mind
+to the other potential slots and simply write (for instance) \texttt{\{0\}}
+or \texttt{\{x=1\}}.%
+\end{minipage}
+
+\subsection{The enhanced mixed partial derivative algorithm\label{subsec:The-enhanced-mixed}}
+
+In the documentation for \texttt{diffcoeff.sty}  I discussed the transition
+table, Table~\ref{tab:Input-output-states}, in which signed \strong{s},
+numeric \strong{n}, or algebraic \strong{a} states changed to one of
+the others, or not, depending on the nature of the current token: sign,
+digit or variable. Signs and digits were explicitly defined; anything and
+everything else was called a (prime) variable. (Not quite true: in fact
+\texttt{diffcoeff.sty} checked for \texttt{(}, \texttt{\textasciicircum{}}
+and \texttt{\_} and raised an error if they were encountered.)\texttt{ }
+
+\begin{table}[h]
+\noindent \begin{centering}
+\caption{A first enhancement}
+\subfloat[\label{tab:Input-output-states}State transitions]{\noindent \centering{}\medskip{}
+\begin{tabular}{ccccc}
+\cmidrule{2-5} 
+ & Curr. state & Curr. token & Action & Next state\tabularnewline
+\cmidrule{2-5} 
+1 & \strong{s} & $s$ & $Ts\to s'$; $T=s'$ & \strong{s}\tabularnewline
+\cmidrule{2-5} 
+2 & \strong{s} & $d$ & $Td$ & \strong{n}\tabularnewline
+\cmidrule{2-5} 
+3 & \strong{s} & $v$ & $Vv$; $T1v$ & \strong{a}\tabularnewline
+\cmidrule{2-5} 
+4 & \strong{n} & $s$ & $\mathbf{N}T$; $T=s$ & \strong{s}\tabularnewline
+\cmidrule{2-5} 
+5 & \strong{n} & $d$ & $Td$ & \strong{n}\tabularnewline
+\cmidrule{2-5} 
+6 & \strong{n} & $v$ & $Vv$; $Tv$ & \strong{a}\tabularnewline
+\cmidrule{2-5} 
+7 & \strong{a} & $s$ & $\mathbf{V}V,$; $V=\textrm{\xD8}$; $\mathbf{A}T$; $T=s$ & \strong{s}\tabularnewline
+\cmidrule{2-5} 
+8 & \strong{a} & $d$ & error & \strong{!!}\tabularnewline
+\cmidrule{2-5} 
+9 & \strong{a} & $v$ & $Vv$; $Tv$ & \strong{a}\tabularnewline
+\cmidrule{2-5} 
+\end{tabular}}
+\par\end{centering}
+\noindent \centering{}\subfloat[\label{tab:Allowing-powers-variables}Allowing powers of variables]{\centering{}%
+\begin{tabular}{ccccc}
+\cmidrule{2-5} 
+ & Curr. state & Curr. token & Action & Next state\tabularnewline
+\cmidrule{2-5} 
+8 & \strong{a} & $d$ & $Vd$; $Td$  & \strong{a}\tabularnewline
+\cmidrule{2-5} 
+\end{tabular}}
+\end{table}
+There is a certain inner logic at play here. Multi-token variables like
+$kmn$ are included in the above scheme. But having accommodated $mn$,
+surely one should be able to handle $mm$, i.e. $m^{2}$? And if $m^{2}$,
+then why not $m^{n}$? In fact it is easy to do so. Since the superscript
+token \textasciicircum{} is neither sign nor digit, no longer raise an
+error if it is encountered but treat it, among the `everything else'
+tokens, as a variable. If we change row 8 of the table as in Table~\ref{tab:Allowing-powers-variables}
+we have enlarged our scheme to include powers of variables \textendash{}
+not only numerical powers (row 8) but also algebraic powers (row 9). As
+a side-effect, if we also suppress the raising of an error when the subscript
+token \texttt{\_} is encountered, it too will be classified as a variable
+and allow numeric and algebraic subscripts on variables: things like $k_{2}$
+or $k_{n}$.
+
+Implicit in this discussion is the understanding that exponents and subscripts
+are restricted to \emph{single tokens}. Coping with multi-token quantities
+in those positions would entail changes to other parts of the code, which
+I have chosen not to do. 
+
+This is a simple way of enlarging the range of tokens acceptable to the
+overall-order algorithm, but it does assume that the user does \emph{not}
+include a sign as a superscript or subscript. If they do, then when the
+algorithm meets the sign it arrives at row 7 of the table and stores what
+is clearly an unintended variable, something like \texttt{k\textasciicircum{}}
+or \texttt{k\_}. So, we need to check when a sign is met whether the previous
+token was one of \texttt{\textasciicircum{}} or \texttt{\_} and raise an
+error if it was. But then the thought arises: if we are going to the trouble
+of checking for sub- or superscript tokens, why just raise an error? Why
+not incorporate signs in sub- or superscript positions into the scheme?
+
+To this end, we might introduce a fourth state, the \emph{script} state,
+denoted by \strong{p}. A script token, denoted $p$, is one of \texttt{\textasciicircum{}}
+or \texttt{\_}. There is only one way to enter a script state, and that
+is by appending a script token to a \emph{variable}. Appending a script
+token to a sign or number (or, indeed, another script token) raises an
+error. Table~\ref{tab:Enlarged-scheme-transitios} is the result. In this
+scheme, signs can be used as sub- or superscripts to variables, but not
+to numbers. We might console ourselves with the thought that this is, in
+any case, a limitation of the calculational engine used to evaluate our
+integer expressions. The \texttt{l3int} module of the LaTeX3 bundle \texttt{l3kernel}
+cannot handle powers of integers.
+
+\begin{table}[h]
+\caption{\label{tab:Enlarged-scheme-transitios}Transition states for an enlarged
+scheme}
+
+\noindent \centering{}%
+\begin{tabular}{ccccc}
+\cmidrule{2-5} 
+ & Curr. state & Curr. token & Action & Next state\tabularnewline
+\cmidrule{2-5} 
+1 & \strong{s} & $s$ & $Ts\to s'$; $T=s'$ & \strong{s}\tabularnewline
+\cmidrule{2-5} 
+2 & \strong{s} & $d$ & $Td$ & \strong{n}\tabularnewline
+\cmidrule{2-5} 
+3 & \strong{s} & $v$ & $Vv$; $T1v$ & \strong{a}\tabularnewline
+\cmidrule{2-5} 
+4 & \strong{s} & $p$ & error & \strong{!!}\tabularnewline
+\cmidrule{2-5} 
+5 & \strong{n} & $s$ & $\mathbf{N}T$; $T=s$ & \strong{s}\tabularnewline
+\cmidrule{2-5} 
+6 & \strong{n} & $d$ & $Td$ & \strong{n}\tabularnewline
+\cmidrule{2-5} 
+7 & \strong{n} & $v$ & $Vv$; $Tv$ & \strong{a}\tabularnewline
+\cmidrule{2-5} 
+8 & \strong{n} & $p$ & error & \strong{!!}\tabularnewline
+\cmidrule{2-5} 
+9 & \strong{a} & $s$ & $\mathbf{V}V,$; $V=\textrm{\xD8}$; $\mathbf{A}T$; $T=s$ & \strong{s}\tabularnewline
+\cmidrule{2-5} 
+10 & \strong{a} & $x\in\{dv\}$  & $Vx$; $Tx$ & \strong{a}\tabularnewline
+\cmidrule{2-5} 
+11 & \strong{a} & $p$ & $Vp$; $Tp$ & \strong{p}\tabularnewline
+\cmidrule{2-5} 
+12 & \strong{p} & $x\in\{sdv\}$  & $Vx$; $Tx$ & \strong{a}\tabularnewline
+\cmidrule{2-5} 
+13 & \strong{p} & $p$ & error & \strong{!!}\tabularnewline
+\cmidrule{2-5} 
+\end{tabular}
+\end{table}
+Yet this still leaves an unfinished feeling. While attaching a script token
+to a sign or other script token is a nonmathematical usage, attaching a
+superscript token to a number is a basic mathematical use, and so two of
+the errors raised can really be ignored. For the other, the question nags:
+why should we have to remember that although variables can be raised to
+powers, numbers cannot be? The urge to enlarge the scheme again is irresistible.
+Exponents on numbers should be accepted; but subscripts should not. The
+latter is a nonmathematical usage or is used only in special contexts remote
+from the present one. But that means we need to distinguish sub- and superscript
+tokens. We can't lump them together as `script tokens'.
+
+\subsubsection{Raising numbers to powers: new states}
+
+So a first step is to enlarge the number of states. We need an \emph{exponent}
+state \strong{e} when we encounter the token \textasciicircum{} and a
+\emph{subscript }state \strong{b} when we encounter the token \_. That
+allows us to distinguish acceptable forms like \texttt{2\textasciicircum{}3}
+($2^{3}$) from unacceptable ones like \texttt{2\_3} ($2_{3}$). But how
+do we know which state to transition to when we meet the \texttt{3} in
+\texttt{2\textasciicircum{}3}? The current state is the exponent one \strong{e}
+and the \texttt{3} could be decorating either a variable or a number. We
+need to know the \emph{previous} state as well as the current one. If the
+previous state is numeric we transition to a numeric state; if it is algebraic,
+we transition to an algebraic state.
+
+But that also introduces a problem. It is perfectly acceptable to add a
+digit to a term in a numeric state. Normally, this is how a multi-digit
+number is accumulated: \texttt{23}4, two hundred and thirty four. That
+is a very different meaning from \texttt{2\textasciicircum{}34} which means
+$2^{3}4$ to us (rather than $2^{34}$ since we accept only single-token
+superscripts). At this point, the syntax required by the underlying engine
+used for evaluating numerical expressions comes into play. For all numerical
+evaluations except those involving exponents, \texttt{l3int} of the LaTeX3
+kernel is used; for expressions involving exponents, \texttt{l3fp} is used.
+To \texttt{l3fp}, \texttt{2\textasciicircum{}34} is read as $2^{34}$.
+We need to insert a multiplication token between the \texttt{3} and \texttt{4},
+which for \texttt{l3fp} is the asterisk, \texttt{{*}}. Considering the
+different tokens that might follow \emph{that}, we are forced to introduce
+a third new state, the \emph{multiplicative} state, \strong{m}. So, to
+introduce powers of numbers means considering three new states and reference
+to the previous state.
+
+That, of course, is \emph{numeric} powers of numbers. To also allow algebraic
+powers, forms like $2^{n}$, introduces further complication. These can't
+be evaluated numerically, so presumably they are to be classified as variables.
+We need to consider terms like $+2^{n}$, $3*2^{n}$, $3^{m}2^{n}$, and
+$2^{n}m$. The problem here is that we have something that looks as if
+it is going to be a number (the digit 2) but then transforms into a variable,
+$2^{n}$. Do we need a \emph{fourth} new state, the entangled state \strong{q}
+(the `q' as in `quantum entanglement')?
+
+\begin{table}
+\noindent \centering{}\caption{\label{tab:Revised-input-output}State transitions of the full scheme}
+\medskip{}
+\begin{tabular}{cccccc}
+\cmidrule{2-6} 
+ & $S_{-}$ & $S$ & $t\in\left\{ sdv\text{\textasciicircum\_}*\right\} $ & Action & $S_{+}$\tabularnewline
+\cmidrule{2-6} 
+1 &  & \strong{s} & $s$ & $Ts\to s'$; $T=s'$ & \strong{s}\tabularnewline
+\cmidrule{2-6} 
+2 &  & \strong{s} & $d$ & $Qd$; $Td$ & \strong{n}\tabularnewline
+\cmidrule{2-6} 
+3 &  & \strong{s} & $v$ & $Vv$; $T1v$ & \strong{a}\tabularnewline
+\cmidrule{2-6} 
+4 &  & \strong{n} & $s$ & $Q=\textrm{\xD8}$; $\mathbf{N}T$; $T=s$ & \strong{s}\tabularnewline
+\cmidrule{2-6} 
+5 &  & \strong{n} & $d$  & $Qd$; $Td$  & \strong{n}\tabularnewline
+\cmidrule{2-6} 
+6 &  & \strong{n} & $v$ & $Q=\textrm{\xD8}$; $Vv$; $Tv$ & \strong{a}\tabularnewline
+\cmidrule{2-6} 
+7 &  & \strong{n} & $\text{\textasciicircum}$ & $Q\text{\textasciicircum}$; $T\text{\textasciicircum}$ & \strong{e}\tabularnewline
+\cmidrule{2-6} 
+8 &  & \strong{n} & $*$ & $Q=\textrm{\xD8}$; $T*$ & \strong{m}\tabularnewline
+\cmidrule{2-6} 
+9 &  & \strong{a} & $s$ & $\mathbf{V}V,$; $V=\textrm{\xD8}$; $\mathbf{A}T$; $T=s$ & \strong{s}\tabularnewline
+\cmidrule{2-6} 
+10 & \strong{e} & \strong{a} & $d$ & $Vd$; $Td$ & \strong{a}\tabularnewline
+\cmidrule{2-6} 
+11 &  & \strong{a} & $v$ & $Vv$; $Tv$ & \strong{a}\tabularnewline
+\cmidrule{2-6} 
+12 &  & \strong{a} & $\text{\textasciicircum}$ & $V\text{\textasciicircum}$; $T\text{\textasciicircum}$ & \strong{e}\tabularnewline
+\cmidrule{2-6} 
+13 &  & \strong{a} & $\text{\_}$ & $V\text{\_}$; $T\text{\_}$ & \strong{b}\tabularnewline
+\cmidrule{2-6} 
+14 & \strong{a} & \strong{e} & $t\in\left\{ sdv\right\} $ & $Vt$; $Tt$  & \strong{a}\tabularnewline
+\cmidrule{2-6} 
+15 & \strong{n} & \strong{e} & $d$ & $Q=\textrm{\xD8}$; $Td*$ & \strong{m}\tabularnewline
+\cmidrule{2-6} 
+16 & \strong{n} & \strong{e} & $v$ & $Qv$; $Tv$; $V=Q$; $Q=\textrm{\xD8}$ & \strong{a}\tabularnewline
+\cmidrule{2-6} 
+17 & \strong{a} & \strong{b} & $t\in\left\{ sdv\right\} $ & $Vt$; $Tt$  & \strong{a}\tabularnewline
+\cmidrule{2-6} 
+18 & \strong{e} & \strong{m} & $s$ & $T1$; $\mathbf{N}T$; $T=s$ & \strong{s}\tabularnewline
+\cmidrule{2-6} 
+19 &  & \strong{m} & $d$ & $Qd$; $Td$  & \strong{n}\tabularnewline
+\cmidrule{2-6} 
+20 &  & \strong{m} & $v$ & $Vv$; $T1v$ & \strong{a}\tabularnewline
+\cmidrule{2-6} 
+21 &  & \strong{m} & $*$ &  & \strong{m}\tabularnewline
+\cmidrule{2-6} 
+\end{tabular}
+\end{table}
+In fact I find that these problems can all be dealt with not by creating
+another state but by including another accumulator for \emph{potential}
+variables. I'll call it $Q$ (from the quantum suggestion, or perhaps quasi-variable,
+or even acqumulator). It stores numbers whose status has not been determined
+yet: they might yet be followed by a superscript token which might in turn
+be followed by a variable. Once resolved, $Q$ either transfers its contents
+to $V$, the variable accumulator, and is emptied (row 16), or is emptied
+forthwith (rows 4, 6, 8, 15).
+
+Table~\ref{tab:Revised-input-output} lists the transitions. I've denoted
+the previous state by $S_{-}$, the present state by $S$, and the next
+state by $S_{+}$. The final row of the table is intended: do nothing if
+we meet a multiplicative token when in a multiplicative state. The first
+scan through an order specification (to split it into numeric and algebraic
+parts) may introduce a {*} token (rows 8 and 15). We don't want to introduce
+a second such token in the recursive determination of the coefficients
+of variables. Hence row 21: do nothing. Also, if in the order specification
+we have something like $2^{3}*3^{2}$ (since \texttt{2\textasciicircum{}33\textasciicircum{}2}
+looks weird), we don't want the manually inserted {*} to cause an error
+because of the automatically inserted one (row 15).
+
+Possibilities not explicitly present in the table generally raise an error,
+e.g. current state \strong{s} and current token $\textnormal{\textasciicircum}$,
+or previous state \strong{n}, current state \strong{e} and current token
+$s$ ($+$ or $-$), and so on. I have omitted them from the table in the
+interests of space. The table is big enough already.
+
+With this table of transitions it is now possible to handle order specifications
+that include components like $n^{2}$ or $n^{m}$ or $k^{+}$ or $k_{2}$
+or $k_{n}$ or $2^{2}$ or $2^{3}3^{2}$ or $2\times3^{n}$ or $2^{2}3^{n}$
+or \ldots{} 
+
+Note that the \texttt{\textbackslash{}times} token is converted internally
+by \texttt{diffcoeffx.sty} to the asterisk. They can be used interchangeably
+but it certainly looks more elegant. 
+
+So, what could be better on a cool winter's evening, snug before the warmth
+of the fire, a glass of sustaining liquid to hand, than to do a few mixed
+partial derivatives? Like this,
+\begin{example}
+\textbackslash{}diffp{[}3\textasciicircum{}22\textasciicircum{}22\textasciicircum{}n+m,12\textasciicircum{}n-3m+2\textasciicircum{}3k,5m+2\textbackslash{}times2\textasciicircum{}32\textasciicircum{}n{]}\{F(x,y,z)\}\{x,y,z\}$\Longrightarrow\quad{\displaystyle \diffp[3^{2}2^{2}2^{n}+m,12^{n}-3m+2^{3}k,5m+2\times2^{3}2^{n}]{F(x,y,z)}{x,y,z}}$
+\end{example}
+or like this,
+\begin{example}
+\textbackslash{}diffp{[}k\textasciicircum{}+k\_-+1,2\textbackslash{}times
+k\_-,3\textasciicircum{}2k\_-,3k\textasciicircum{}+{]}\{F(x,y,z,w)\}\{x,y,z,w\}
+${\displaystyle \Longrightarrow\quad\diffp[k^{+}k_{-}+1,2\times k_{-},3^{2}k_{-},3k^{+}]{F(x,y,z,w)}{x,y,z,w}}$
+\end{example}
+In the first example the \texttt{\textbackslash{}times} symbol is inserted
+by \texttt{diffcoeffx} in the overall order of differentiation in the numerator
+so as to prevent the formation $522^{n}$ which would be read as 522 raised
+to the power $n$ \textendash{} and for a similar reason it was used in
+specifying the order of differentiation of the variable $z$ in the denominator
+in the first example, but could and should have been deleted from the order
+of differentiation of the variable $y$ in the second example. 
+
+\subsubsection{Parentheses}
+
+The other major shortcoming of the basic scheme outlined in \texttt{diffcoeff.sty}
+was the inability to handle even the simplest instance of parentheses in
+an order specification \textendash{} something like\texttt{ {[}m-(n-1),m+(n-1){]}}
+which might well arise in a Taylor expansion. Indeed, there is more reason
+for including these in our scheme than exponents of numbers or $+$ or
+$-$ as sub- or superscripts. 
+
+How might we fit parentheses to the scheme? We are not seeking a general
+treatment. Rather we wish to be able to handle order specifications a little
+more complicated (but only a little) than the one just given, say something
+like \texttt{{[}m+2(n-1),m-(n-1){]}}, perhaps with nesting. In that case
+the following stipulations meet our needs:
+\begin{itemize}
+\item a left parenthesis, (, either starts an item in the comma list, or is preceded
+by a sign or a number or $*$ or (, but \emph{not} by a variable or \textasciicircum{}
+or \_ or );
+\item a right parenthesis, ), either concludes an item in the comma list, or
+is followed by a sign or ), but \emph{not} by a number or a variable or
+\textasciicircum{} or \_ or $*$ or (.
+\end{itemize}
+These limitations allow nesting of parentheses but not products of parentheses.
+The main limitation they impose is that a variable lie \emph{within} parentheses
+but not adjoining-outside. They enable us to get away with the following
+`cheap and cheerful' scheme. It means we do not need to add parenthesis
+states to our scheme. The particular point to note are the $+0$ insertions.
+When we start parsing an expression from the left we do not know what it
+contains. In particular when we meet a left parenthesis, we have no foreknowledge
+of whether the parenthesised expression will be numeric, algebraic or a
+mix of both. We need to prepare for both by inserting a left parenthesis
+to both numeric and algebraic parts. But that brings us up against a quirk
+of \texttt{l3int}, the `engine' behind the numerical evaluations performed
+in \texttt{diffcoeff} and \texttt{diffcoeffx}. \texttt{l3int} objects to
+an empty pair of parentheses, \texttt{()}, which we would have should either
+numeric or algebraic parts be missing from the parenthesised expression.
+To avoid this we insert $+0$ and \texttt{l3int} is happy.\texttt{ }
+
+\begin{table}
+\centering{}\caption{\label{tab:Parentheses}Parentheses}
+\begin{tabular}{ccccc}
+\cmidrule{2-5} 
+ & Curr. state & Curr. token & Action & Next state\tabularnewline
+\cmidrule{2-5} 
+1 & \strong{s} & ( & $T\text{1*(}$; $\mathbf{N}T$; $\mathbf{A}T$; $T=+$ & \strong{s}\tabularnewline
+\cmidrule{2-5} 
+2 & \strong{s} & ) & $\mathbf{N})$; $\mathbf{A})$ & \strong{s}\tabularnewline
+\cmidrule{2-5} 
+3 & \strong{n} & ( & $T*($; $\mathbf{N}T$; $\mathbf{A}T$; $T=+$ & \strong{s}\tabularnewline
+\cmidrule{2-5} 
+4 & \strong{n} & ) & $T)$; $\mathbf{N}T$; $\mathbf{A}\text{+0)}$; $T=+$ & \strong{s}\tabularnewline
+\cmidrule{2-5} 
+5 & \strong{a} & ) & $\mathbf{V}V,$; $V=\textrm{\xD8}$; $\mathbf{N}\text{+0)}$; $T)$; $\mathbf{A}T$
+; $T=+$ & \strong{s}\tabularnewline
+\cmidrule{2-5} 
+6 & \strong{m} & ( & $T($; $\mathbf{N}T$; $\mathbf{A}T$; $T=+$ & \strong{s}\tabularnewline
+\cmidrule{2-5} 
+\end{tabular}
+\end{table}
+
+\begin{itemize}
+\item Row 1. Quirks of the \texttt{l3int} module of the \LaTeX{}3 kernel mean
+we need to insert \strong{1{*}} before the left parenthesis.\footnote{Specifically, \texttt{\textbackslash{}int\_eval\{}\textbf{ }\texttt{\textendash (}
+or \texttt{\textbackslash{}int\_eval\{}\textbf{ }\texttt{+(} throw errors.} Note that we add $T$ to \emph{both} the numeric and algebraic parts of
+the expression. We are working through our expression $\mathbf{E}$ from
+the left, token by token, and have no foreknowledge of what the parenthesised
+expression contains, whether algebraic terms only or numeric terms only
+or some combination of both. Hence the need to prepare for both. The system
+shifts to a signed state \strong{s} with $T=+$, exactly the same as when
+beginning to scan $\mathbf{E}$. After all, the parenthesised expression
+is an expression in itself.
+\item Row 2. This is to allow nested parentheses like )). It shouldn't arise
+otherwise. Because of rows 4 and 5, the first right parenthesis puts the
+system into a signed state. The current term will be $T=+$, but we ignore
+it and store only a right parenthesis in both numeric and algebraic parts.
+\item Row 3. We already have a number present in $T$; only the asterisk needs
+inserting before the parenthesis. Again we add $T$ to \emph{both} the
+numeric and algebraic parts of the expression, initialise $T$ to $+$
+and change the state to a signed one.
+\item Row 4. We are in a numeric state. We append ) to the current term and the
+current term to the numeric part of the expression. We append $+0)$ to
+the algebraic part, and shift to a signed state \strong{s} with $T=+$,
+as at the outset. The $+0)$ in the algebraic part is necessary to prevent
+an empty parenthesis pair in $\mathbf{A}$ should the parenthesised expression
+have contained \emph{no} algebraic term.
+\item Row 5. We are in an algebraic state. We append ) to the current term and
+the current term to the algebraic part of the expression. We append $+0)$
+to the numeric part and shift to the initial signed state again. The $+0)$
+in the numeric part is necessary to prevent an empty parenthesis pair in
+$\mathbf{N}$ should the parenthesised expression have contained \emph{no}
+numeric term.
+\item Row 6. We are in the new state, the multiplicative state, and the current
+token is a left parenthesis. We have already met and inserted an asterisk
+(row 5); we don't need to insert another. We append ( to $T$, $T$ to
+both numeric and algebraic parts and shift to the initial signed state
+again. The use of the multiplicative state prevents a string of asterisks
+arising (but we have been able to avoid introducing new states for left
+and right parentheses).
+\end{itemize}
+To work through an example, suppose we have an order specificiation \strong{{[}m+(n\textendash (k\textendash 1)),m\textendash{} 2(n+(k\textendash 1)),k{]}}.
+(Digit \strong{1} rather than a lower-case letter \strong{l} within the
+parentheses!) Concatenating, with linking + signs gives \strong{m+(n\textendash (k-1))+m\textendash 2(n+(k\textendash 1))+k}.
+Splitting into numeric and algebraic parts now results in \strong{+1{*}(\textendash 1{*}(\textendash 1))\textendash 2{*}(+1{*}(\textendash 1))}
+for the numeric part, evaluating to \strong{3}, and \strong{+1m+1{*}(+1n\textendash 1{*}(+1k+0))+1m\textendash 2{*}(+1n+1{*}(+1k+0))+1k}
+for the algebraic part. 
+
+Removing \strong{m} from the latter and splitting into numeric and algebraic
+parts gives \strong{+1+ 1{*}(\textendash 1{*}(+0))+1\textendash 2{*}(+1{*}(+0))}
+for the numeric part, evaluating to \strong{2} which is the overall coefficient
+of \strong{m}, and \strong{+1{*}(+1n\textendash 1{*}(+1k+0))\textendash 2{*}(+1n+1{*}(+1k+0))+1k}
+for the algebraic part.
+
+Now remove \strong{n} from this resulting algebraic part and again split
+into parts. The result is \strong{+1{*}(+1-1{*}(+0))\textendash 2{*}(+1+1{*}(+0))}
+for the numeric part, evaluating to \strong{\textendash 1} which is the
+overall coefficient of \strong{n}, and \strong{+1{*}(\textendash 1{*}(+1k+0))\textendash 2{*}(+1{*}(+1k+0))+1k}
+for the algebraic part. 
+
+Removing \strong{k} from this and splitting gives \strong{+1{*}(\textendash 1{*}(+1+0))\textendash 2{*}(+1{*}(+1+0))+1}
+for the numeric part, evaluating to \strong{\textendash 2} which is the
+overall coefficient of \strong{k}, and \strong{+1{*}(\textendash 1{*}(+0)) \textendash 2{*}(+1{*}(+0))}
+for the algebraic part. But we have run out of variables and so the process
+stops at this point:
+\begin{example}
+\textbackslash{}diffp{[}m+(n-(k-1)),m-2(n+(k-1)),k{]}F\{x,y,z\}$\Longrightarrow{\displaystyle \hspace*{1em}\diffp[m+(n-(k-1)),m-2(n+(k-1)),k]F{x,y,z}}$
+\end{example}
+
+\end{document}


Property changes on: trunk/Master/texmf-dist/doc/latex/diffcoeff/diffcoeffx.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff.sty	2016-06-27 20:41:31 UTC (rev 41554)
@@ -0,0 +1,711 @@
+% This is file `diffcoeff.sty'.
+%
+% This program is free software; you can redistribute it and/or modify it 
+% under the terms of the GNU General Public License as published by the 
+% Free Software  Foundation; either version 2 of the License, or (at your
+% option) any later version.
+% 
+% Andrew Parsloe aparsloe at clear.net.nz
+%
+\RequirePackage{expl3}
+\RequirePackage{xparse}
+\ProvidesExplPackage{diffcoeff} {2016/06/27} {1.0} 
+  {Write differential coefficients easily.}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\cs_generate_variant:Nn \tl_if_eq:nnF { no }
+\cs_generate_variant:Nn \tl_if_eq:nnT { no }
+\cs_generate_variant:Nn \tl_if_in:NnTF { NV }
+\cs_generate_variant:Nn \prop_pop:NnNT { NV }
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% variables
+\tl_new:N \g_diffco_d_ldelim_tl
+\tl_new:N \g_diffco_d_rdelim_tl
+\tl_new:N \g_diffco_p_ldelim_tl
+\tl_new:N \g_diffco_p_rdelim_tl
+
+\tl_new:N \l__diffco_entiand_tl 
+\tl_new:N \l__diffco_phantom_tl
+\tl_new:N \g_diffco_dop_tl
+\tl_new:N \l__diffco_denom_tl
+\tl_new:N \l__diffco_coeff_tl
+
+\clist_new:N \l__diffco_order_clist
+\tl_new:N \l__diffco_order_spec_tl
+
+\bool_new:N \g__diffco_erent_shape_bool
+\bool_new:N \l__diffco_no_parens_bool
+\bool_new:N \l__diffco_override_bool
+\bool_new:N \l__diffco_vars_noted_bool
+ 
+\tl_new:N \l__diffco_orders_in_tl
+\tl_new:N \l__diffco_order_tl
+
+\tl_new:N \l__diffco_curr_tok_tl
+\tl_new:N \l__diffco_curr_term_tl
+
+\int_new:N \l__diffco_curr_tok_int
+\int_new:N \l__diffco_curr_state_int
+
+\prop_new:N \l__diffco_vars_prop
+\tl_new:N \l__diffco_vars_tl
+\clist_new:N \l__diffco_vars_clist
+
+\tl_new:N \l__diffco_curr_var_tl
+\tl_new:N \l__diffco_nos_tl
+\tl_new:N \l__diffco_nos_aux_tl
+
+\tl_new:N \l__diffco_alg_tl
+\tl_new:N  \l__diffco_alg_aux_tl
+\tl_new:N \l__diffco_alg_expr_tl
+
+\tl_const:Nn \c__diffco_digits_tl { 1234567890 }
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\keys_define:nn { diffcoeff }
+  {
+  roman .bool_gset:N  = \g_diffco_roman_bool, 
+  roman .default:n = { false }, 
+  d-delims .code:n = { 
+                      \tl_gset:Nx \g_diffco_d_ldelim_tl { \left \use_i:nn #1 }
+                      \tl_gset:Nx \g_diffco_d_rdelim_tl 
+                          { \right \use_ii:nn #1 }
+                      },
+  d-delims .default:n = { .| },
+  p-delims .code:n = { 
+                      \tl_gset:Nx \g_diffco_p_ldelim_tl { \left \use_i:nn #1 }
+                      \tl_gset:Nx \g_diffco_p_rdelim_tl 
+                          { \right \use_ii:nn #1 }
+                      },
+  p-delims .default:n = { () },
+  d-nudge .code:n = { \tl_gset:Nn \g_diffco_d_nudge_tl { \mskip #1 mu } },
+  d-nudge .default:n = { 0 },
+  p-nudge .code:n = { \tl_gset:Nn \g_diffco_p_nudge_tl { \mskip #1 mu } },
+  p-nudge .default:n = { -6 },
+  sep .code:n = { \tl_gset:Nn \g_diffco_sep_tl { \mskip #1 mu } },
+  sep .default:n = { 2 },
+  d-sep .code:n = { \tl_gset:Nn \g_diffco_d_sep_tl { \mskip #1 mu } },
+  d-sep .default:n = { 1 },
+  p-sep .code:n = { \tl_gset:Nn \g_diffco_p_sep_tl { \mskip #1 mu } },
+  p-sep .default:n = { 1 },
+  }  
+
+\DeclareDocumentCommand \diffset { o }
+  {
+  \IfValueTF { #1 }
+    { 
+    \clist_if_empty:nTF { #1 }
+      { \keys_set:nn { diffcoeff } { roman,d-delims,p-delims,
+      d-nudge,p-nudge,sep,d-sep,p-sep } }
+      { \keys_set:nn { diffcoeff } { #1 } }
+    }
+    { 
+    \keys_set:nn { diffcoeff } { roman,d-delims,p-delims,
+    d-nudge,p-nudge,sep,d-sep,p-sep }  
+    }
+  }
+     
+% now set the defaults    
+\diffset  
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Derivatives
+% Ordinary differential coefficient. #1 is the order; #2 the 
+% differentiand; #3 the variable of differentiation; #4 the 
+% point of evaluation. 
+\NewDocumentCommand \diff{ s o m t/ m g } 
+  {
+  \group_begin:
+  % roman or italic?
+  \bool_if:NF \g__diffco_erent_shape_bool
+    { \__diffco_shape:N d }
+  
+  \IfValueTF { #2 } 
+    { 
+    \tl_set:Nn \l__diffco_order_tl { ^{ \g_diffco_d_sep_tl #2 } }
+    \int_compare:nNnTF { \tl_count:n { #5 } } > { \c_one }
+      { \tl_set:Nn \l__diffco_denom_tl { (#5)^{ #2 } } }
+      { \tl_set:Nn \l__diffco_denom_tl { #5^{ #2 } } }
+    }
+    { 
+    \tl_set:Nn \l__diffco_order_tl { }
+    \tl_if_in:nnTF { #5 } { ^ }
+      { \tl_set:Nn \l__diffco_denom_tl { (#5) } }
+      { \tl_set:Nn \l__diffco_denom_tl { #5 } } 
+    }
+  
+% position of differentiand: appended (star) or numerator (no star);
+% slash or fraction?
+  \IfBooleanTF { #1 }
+    { % differentiand follows diff coeff 
+    \__diffco_phantom:n { #3 }
+    \tl_set:Nn \l__diffco_coeff_tl
+      {
+      \IfBooleanTF { #4 }
+        { % slash (therefore no phantom)
+        (\g_diffco_dop_tl \l__diffco_order_tl 
+        /
+        \g_diffco_dop_tl \l__diffco_denom_tl )
+        \l__diffco_entiand_tl
+        }
+        { % frac
+        \frac { \g_diffco_dop_tl \l__diffco_order_tl \l__diffco_phantom_tl }
+            { \g_diffco_dop_tl \l__diffco_denom_tl } \l__diffco_entiand_tl
+        }
+      }
+    }
+    { % differentiand in numerator
+    \tl_set:Nn \l__diffco_coeff_tl
+      {
+      \IfBooleanTF { #4 }
+        { % slash
+        \g_diffco_dop_tl \l__diffco_order_tl #3
+        /
+        \g_diffco_dop_tl \l__diffco_denom_tl 
+        }
+        { % frac
+        \frac { \g_diffco_dop_tl \l__diffco_order_tl #3  }
+          { \g_diffco_dop_tl \l__diffco_denom_tl }
+        }
+      }
+    }
+  % pt of eval
+  \IfNoValueTF { #6 } 
+    { 
+    \l__diffco_coeff_tl
+    }
+    { % trailing arg: pt of eval.
+    \tl_if_empty:nTF { #6 }
+      { 
+      \l__diffco_coeff_tl
+      }
+      {
+      \g_diffco_d_ldelim_tl \l__diffco_coeff_tl \g_diffco_d_rdelim_tl 
+      \c_math_subscript_token { \g_diffco_d_nudge_tl #6 }
+      }
+    }
+  \group_end:  
+  }  
+  
+\NewDocumentCommand \Diff { o m m g }
+  {
+  \group_begin:
+  \__diffco_shape:N D 
+  \bool_gset_true:N \g__diffco_erent_shape_bool
+  \diff[#1]{#2}{#3}{#4}
+  \bool_gset_false:N \g__diffco_erent_shape_bool
+  \group_end:
+  }
+  
+\NewDocumentCommand \diffd { o m m g } 
+  {
+  \group_begin:
+  \__diffco_shape:N \delta
+  \bool_gset_true:N \g__diffco_erent_shape_bool
+  \diff[#1]{#2}{#3}{#4}
+  \bool_gset_false:N \g__diffco_erent_shape_bool
+  \group_end:
+  }
+  
+\NewDocumentCommand \Diffd { o m m g }
+  {
+  \group_begin:
+  \__diffco_shape:N \Delta
+  \bool_gset_true:N \g__diffco_erent_shape_bool
+  \diff[#1]{#2}{#3}{#4}
+  \bool_gset_false:N \g__diffco_erent_shape_bool
+  \group_end:
+  }
+    
+\cs_new_nopar:Npn \__diffco_shape:N #1    
+  {
+  \bool_if:NTF \g_diffco_roman_bool
+    { \tl_gset:Nn \g_diffco_dop_tl { \mathrm{ #1} } }
+    { \tl_gset:Nn \g_diffco_dop_tl { #1 } }
+  } 
+%%%%%
+\cs_new:Npn \__diffco_append:nn #1#2
+  {
+  \g_diffco_d_ldelim_tl \l__diffco_coeff_tl \g_diffco_d_rdelim_tl 
+    \c_math_subscript_token { \mskip #1 mu #2 }
+  }
+  
+\cs_new:Npn \__diffco_phantom:n #1
+  {
+  \bool_if:nTF
+      {
+      \tl_if_head_eq_meaning_p:nN { #1 } \hfill ||
+      \tl_if_head_eq_meaning_p:nN { #1 } \hfil
+      }
+      {
+      \l__diffco_phantom_aux:nn #1\q_stop
+      }
+      {
+      \bool_if:nTF
+        {
+        \tl_if_head_eq_meaning_p:nN { #1 } \hspace ||
+        \tl_if_head_eq_meaning_p:nN { #1 } \hphantom
+        }
+        {
+        \l__diffco_phantom_aux:nnn #1\q_stop
+        }
+        {
+        \tl_set:Nn \l__diffco_entiand_tl { #1 } 
+        }
+      }
+  }
+
+\cs_new:Npn \l__diffco_phantom_aux:nn #1#2\q_stop
+  {
+  \tl_set:Nn \l__diffco_phantom_tl { #1 }
+  \tl_set:Nn \l__diffco_entiand_tl { #2 }
+  }
+  
+\cs_new:Npn \l__diffco_phantom_aux:nnn #1#2#3\q_stop
+  {
+  \tl_set:Nn \l__diffco_phantom_tl { #1 { #2  } }
+  \tl_set:Nn \l__diffco_entiand_tl { #3 }
+  }
+%%%%%%%%%%%%%%%%%%%%
+% Partial differential coefficient. 
+% #1 (star) = append differentiand boolean
+% #2 = comma list of the orders of diff. in each var.;
+% #3 = order override for the numerator; #4 = differentiand; 
+% #5 slash / boolean; #6 = comma list of vars of diff.; 
+% #7 = list of vars held const.
+\NewDocumentCommand \diffp{ s o o m t/ m g } 
+  {
+  \group_begin:
+  
+  % diff. order list 
+  \tl_clear:N \l__diffco_order_clist
+  \IfValueT { #2 }
+    { 
+    \clist_set:Nn \l__diffco_order_clist { #2 }
+    \tl_set:Nx \l__diffco_order_spec_tl 
+        { [\clist_use:Nn \l__diffco_order_clist { , }]}
+    }
+  
+  % order list override  
+  \IfValueT { #3 }
+    { 
+    \bool_set_true:N \l__diffco_override_bool
+    \tl_set:Nn \l__diffco_order_tl { #3 } 
+    }
+    
+  \__diffco_orders:Nn \l__diffco_order_clist { #6 }
+
+  % position of differentiand
+  \IfBooleanTF { #1 }
+    { % appended
+    \__diffco_phantom:n { #4 }
+    \tl_set:Nn \l__diffco_coeff_tl
+        {
+        \IfBooleanTF { #5 }
+          { % slash (therefore no phantom)
+          ( \partial \__diffco_omit_order_if_i:N
+          \l__diffco_order_tl
+          /
+          \l__diffco_denom_tl ) \l__diffco_entiand_tl
+          }
+          { % frac
+          \frac { \partial \__diffco_omit_order_if_i:N
+            \l__diffco_order_tl \l__diffco_phantom_tl } 
+            { \l__diffco_denom_tl } \l__diffco_entiand_tl
+          }
+        }
+    }
+    { % in numerator
+    \tl_set:Nn \l__diffco_coeff_tl
+        {
+        \IfBooleanTF { #5 }
+          {
+          \partial \__diffco_omit_order_if_i:N \l__diffco_order_tl #4 
+          / \l__diffco_denom_tl
+          }
+          {
+          \frac { \partial
+             \__diffco_omit_order_if_i:N \l__diffco_order_tl
+             #4 } { \l__diffco_denom_tl } 
+          }
+        }
+    }
+
+  \IfNoValueTF { #7 }
+    { 
+    \l__diffco_coeff_tl 
+    }
+    {
+    \tl_if_empty:nTF { #7 }
+      { 
+      \l__diffco_coeff_tl
+      }
+      {
+      \g_diffco_p_ldelim_tl \l__diffco_coeff_tl \g_diffco_p_rdelim_tl
+      \c_math_subscript_token { \g_diffco_p_nudge_tl #7 }
+      }
+    }
+  \group_end:  
+  } % end of \diffp 
+
+\NewDocumentCommand \jacob { m m }
+  { % need extra braces in denom for clist manipulations
+  \diffp{ (#1) }{ { {{(#2)}} } }
+  }
+ 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
+
+% #1 is the clist of diff. orders
+% #2 is the tl of variables (if commas present treat as clist)
+\cs_new:Npn \__diffco_orders:Nn #1#2
+  {
+  \int_zero:N \l_tmpa_int
+  \tl_clear:N \l_tmpb_tl
+  \clist_clear:N \l_tmpa_clist
+  \clist_clear:N \l_tmpb_clist
+  \clist_clear:N \l__diffco_vars_clist
+    
+  \clist_set:Nn \l__diffco_vars_clist { #2 }
+  \clist_map_inline:Nn \l__diffco_vars_clist
+    {
+    \bool_set_false:N \l__diffco_no_parens_bool
+    
+    % get order of each variable
+    \clist_pop:NNF #1 \l_tmpa_tl 
+      { \tl_set:Nn \l_tmpa_tl { 1 } }
+
+    \tl_if_eq:noT { 1 } \l_tmpa_tl
+      { \bool_set_true:N \l__diffco_no_parens_bool }
+
+    \clist_put_right:NV \l_tmpa_clist \l_tmpa_tl 
+   
+    % create the denominator
+    \tl_clear:N \l_tmpb_tl
+    \bool_if:nTF
+        {
+        \int_compare_p:nNn { \tl_count:n { ##1 } } = { \c_one } 
+        ||
+        \l__diffco_no_parens_bool
+        }
+      { \tl_put_right:Nn \l_tmpb_tl { \partial ##1 } }
+      { \tl_put_right:Nn \l_tmpb_tl { \partial (##1) } }
+
+    \tl_if_eq:noF { 1 } \l_tmpa_tl
+      { 
+      \tl_put_right:Nn \l_tmpb_tl { ^ } 
+      \tl_put_right:Nx \l_tmpb_tl { { \l_tmpa_tl } }
+      }
+
+    \clist_put_right:No \l_tmpb_clist \l_tmpb_tl
+    } % end of inline map
+
+  % numerator order 
+  \bool_if:NF \l__diffco_override_bool
+    {
+    \tl_set:Nx \l__diffco_orders_in_tl { \clist_use:Nn \l_tmpa_clist {+} }
+    \diff_simplify_orders:NN \l__diffco_orders_in_tl \l__diffco_order_tl
+    }
+
+  % denominator
+  \tl_set:Nx \l__diffco_denom_tl { \clist_use:Nn
+        \l_tmpb_clist { \g_diffco_sep_tl } }
+  }
+
+% don't display order 1 superscript
+\cs_new:Npn \__diffco_omit_order_if_i:N #1
+    {
+    \tl_if_eq:noF { 1 } #1
+      { ^{ \g_diffco_p_sep_tl \l__diffco_order_tl } }
+    }
+%%%%%%%%%%%%%%%%%%%%%%
+% #1 is expr. in; #2 is expr. out
+\cs_new:Npn \diff_simplify_orders:NN #1 #2
+  {
+  \tl_clear:N \l__diffco_nos_tl
+ 
+  \__diffco_digest_expr:NNNN \l__diffco_orders_in_tl \l__diffco_nos_tl 
+      \l__diffco_alg_tl \l__diffco_vars_prop
+
+  \__diffco_eval_nos:N \l__diffco_nos_tl
+  
+  \tl_if_empty:NF \l__diffco_alg_tl
+    { \__diffco_eval_vars:NN \l__diffco_alg_tl \l__diffco_vars_prop }
+  
+  \__diffco_manicure_result:NNN \l__diffco_nos_tl \l__diffco_alg_tl #2
+  }
+
+% #1 is the expression; #2 (tl) receives the numerical part;
+% #3 (tl) receives the algebraic part; #4 (prop) receives the vars
+\cs_new:Npn \__diffco_digest_expr:NNNN #1#2#3#4
+  {
+  \tl_put_right:Nn #1 { + }
+  \tl_set:Nn \l__diffco_curr_term_tl { + }
+  \int_set:Nn \l__diffco_curr_state_int { \c_zero }
+  \int_set:Nn \l__diffco_curr_tok_int { \c_zero }
+  \tl_clear:N #3
+  \prop_clear:N #4
+    
+  \tl_map_inline:Nn #1
+    { 
+    \tl_set:Nn \l__diffco_curr_tok_tl { ##1 }
+    \__diffco_get_curr_index:NN ##1 \l__diffco_curr_tok_int
+    \__diffco_compare_states:NNNNN \l__diffco_curr_state_int 
+        \l__diffco_curr_tok_int #2#3#4
+    }
+  \tl_if_empty:NT #2 { \tl_set:Nn #2 { 0 } }
+  }
+
+% #1 contains current token (tl); #2 receives current state (int)
+\cs_new:Npn \__diffco_get_curr_index:NN #1#2
+  {
+  \tl_if_in:NnTF \c__diffco_digits_tl { #1 }
+    { % digit
+    \int_set:Nn #2 { \c_one }
+    }
+    {
+    \tl_case:NnF #1
+      {
+      + { \int_set_eq:NN #2 \c_zero }
+      - { \int_set_eq:NN #2 \c_zero }
+      ( {
+        \msg_error:nnxx { diffcoeff } { unknown_token } 
+            { \l__diffco_order_spec_tl } { parentheses }
+        }
+      ^ { 
+        \msg_error:nnxx { diffcoeff } { unknown_token }
+            { \l__diffco_order_spec_tl } { superscript } 
+        }
+      }  
+      {
+      \token_if_math_subscript:NTF #1 
+        { 
+        \msg_error:nnxx { diffcoeff } { unknown_token } 
+            { \l__diffco_order_spec_tl } { subscript } 
+        }
+        {  % var 
+        \int_set_eq:NN #2 \c_two 
+        } 
+      }
+    }
+  }
+ 
+% #1 (int) is curr. state; #2 (int) is curr token index; 
+% #3 (tl) receives the numerical part; 
+% #4 (tl) receives the algebraic part; 
+% #5 (prop) receives the vars
+\cs_new:Npn \__diffco_compare_states:NNNNN #1#2#3#4#5
+  {
+  \int_case:nn { #1 }
+    {
+      { \c_zero } % sgn
+        {
+        \int_case:nn { #2 }
+          {
+            { \c_zero } % tok = s
+              {
+              \tl_if_eq:NNTF \l__diffco_curr_term_tl \l__diffco_curr_tok_tl
+                { \tl_set:Nn \l__diffco_curr_term_tl { + } }
+                { \tl_set:Nn \l__diffco_curr_term_tl { - } }
+              % \int_set:Nn #1 { \c_zero }
+              }
+            { \c_one } % tok = d
+              { \__diffco_term_append:NN #1#2 }
+            { \c_two } % tok = v
+              {
+              \tl_put_right:Nn \l__diffco_curr_term_tl { 1 }
+              \__diffco_term_var_append:NN #1#2
+              }
+          }
+        }
+      { \c_one } % num
+        {
+        \int_case:nn { #2 }
+          {
+            { \c_zero } % tok = s
+              {
+              \tl_put_right:NV #3 \l__diffco_curr_term_tl 
+              \tl_clear:N \l__diffco_curr_term_tl
+              \__diffco_term_append:NN #1#2
+              }
+            { \c_one } % tok = d
+              { \__diffco_term_append:NN #1 \c_one }
+            { \c_two } % tok = v
+              { \__diffco_term_var_append:NN #1#2 }
+          }
+        }      
+      { \c_two } % alg
+        {
+        \int_case:nn { #2 }
+          {
+            { \c_zero } % tok = s
+              {
+              \tl_put_right:NV #4 \l__diffco_curr_term_tl
+              \tl_clear:N \l__diffco_curr_term_tl
+              \bool_if:NF \l__diffco_vars_noted_bool
+                { \__diffco_store_var:NN #5 \l__diffco_curr_var_tl }
+              \tl_clear:N \l__diffco_curr_var_tl 
+              \__diffco_term_append:NN #1#2
+              }
+            { \c_one } % tok = d
+              { 
+              \msg_error:nnx { diffcoeff } { variable_digit_sequence } 
+                { \l__diffco_order_spec_tl }
+              }
+            { \c_two } % tok = v
+              { \__diffco_term_var_append:NN #1 \c_two }
+          }
+        }
+    }
+  }
+
+% #1 current state; #2 current token index
+\cs_new:Npn \__diffco_term_var_append:NN #1#2
+  {
+  \tl_put_right:NV \l__diffco_curr_term_tl \l__diffco_curr_tok_tl
+  \tl_put_right:NV \l__diffco_curr_var_tl \l__diffco_curr_tok_tl
+  \int_set_eq:NN #1 #2
+  }
+  
+% #1 current state; #2 current token index
+\cs_new:Npn \__diffco_term_append:NN #1#2
+  {
+  \tl_put_right:NV \l__diffco_curr_term_tl \l__diffco_curr_tok_tl
+  \int_set_eq:NN #1 #2
+  }    
+ 
+% #1 is prop list; #2 is tl containing var
+\cs_new:Npn  \__diffco_store_var:NN #1 #2
+  {
+  \int_set:Nn \l_tmpa_int { \exp_args:NV \tl_count_tokens:n #2 }
+  \prop_get:NVNTF #1 \l_tmpa_int \l_tmpa_tl
+    {
+    \tl_put_right:Nn \l_tmpa_tl { , }
+    \tl_put_right:NV \l_tmpa_tl #2
+    \prop_put:NVV #1 \l_tmpa_int \l_tmpa_tl
+    }
+    {
+    \prop_put:NVV #1 \l_tmpa_int #2
+    }
+  }
+  
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% evals numerical expr. in #1, which receives the
+% evaluated expr.
+\cs_new:Npn \__diffco_eval_nos:N #1 
+  {
+  \int_set:Nn \l_tmpa_int { #1 }
+  \tl_set:Nx  #1 { \int_use:N \l_tmpa_int }
+  \int_compare:nNnT { \l_tmpa_int } > { \c_zero }
+    { \tl_put_left:Nn #1 { + } }
+  }
+
+% #1 (tl) has algebraic part & receives eval. expression
+% #2 (prop) contains the variables
+% The idea is to remove each var but leave coeffs, split into
+% num & alg parts, eval. the num part for the net coeff of var
+\cs_new:Npn \__diffco_eval_vars:NN #1#2
+  { 
+  \bool_set_true:N \l__diffco_vars_noted_bool
+  \prop_set_eq:NN \l_tmpa_prop #2
+  \int_set_eq:NN \l_tmpa_int \c_one
+  \bool_until_do:nn { \prop_if_empty_p:N #2 }
+    {
+    \prop_pop:NVNT #2 \l_tmpa_int \l_tmpa_tl
+      {
+      \tl_put_left:Nn \l_tmpa_tl { , }
+      \tl_put_left:NV \l__diffco_vars_tl  \l_tmpa_tl
+      }
+    \int_incr:N \l_tmpa_int
+    }
+    
+  \clist_set:NV \l__diffco_vars_clist \l__diffco_vars_tl
+  \clist_remove_duplicates:N \l__diffco_vars_clist
+  
+  \clist_map_inline:Nn \l__diffco_vars_clist
+    {
+    \tl_replace_all:Nnn #1 { ##1 } { }
+    \__diffco_digest_expr:NNNN #1 \l__diffco_nos_aux_tl \l__diffco_alg_aux_tl 
+        \l_tmpa_prop
+
+    \__diffco_eval_nos:N \l__diffco_nos_aux_tl
+      
+    \__diffco_cumulate_expr:NnN \l__diffco_nos_aux_tl { ##1 }
+        \l__diffco_alg_expr_tl
+     
+    \tl_set_eq:NN #1 \l__diffco_alg_aux_tl
+    \tl_clear:N \l__diffco_nos_aux_tl
+    \tl_clear:N \l__diffco_alg_aux_tl
+    }
+
+  \tl_set_eq:NN #1 \l__diffco_alg_expr_tl
+  }
+
+% #1 is num coeff; #2 is var; #3 is cumulating expr. (All tl.)
+\cs_new:Npn \__diffco_cumulate_expr:NnN #1#2#3
+  {
+  \int_case:nnF { #1 }
+    {
+      { 0 } { \prg_do_nothing: }
+      { +1 } { \tl_put_right:Nn #3 { + #2 } }
+      { -1 } { \tl_put_right:Nn #3 { - #2 } }
+    }
+    {
+    \tl_put_right:NV #3 { #1 } 
+    \tl_put_right:Nn #3 { #2 }
+    }
+  }
+
+% alg. part precedes num. part unless alg. starts 
+% with - and nums > 0. #1 nums, #2 alg, #3 output 
+\cs_new:Npn \__diffco_manicure_result:NNN #1#2#3
+  { % alg < 0 ?
+  \exp_args:NV \tl_if_head_eq_charcode:nNTF #2 -
+    {
+    \int_compare:nNnTF { #1 } > { \c_zero }
+      {  % nums > 0
+      \tl_concat:NNN #3 #1 #2
+      }
+      {  % nums =< 0
+      \seq_set_split:NnV \l_tmpa_seq { + } #2    
+      \seq_pop:NN \l_tmpa_seq \l_tmpa_tl
+      \tl_set:Nx \l_tmpb_tl { \seq_use:Nn \l_tmpa_seq { + } }
+      \int_compare:nNnF { #1 } = { \c_zero }
+        { \tl_concat:NNN \l_tmpa_tl \l_tmpa_tl #1 }
+      \tl_concat:NNN #3 \l_tmpb_tl \l_tmpa_tl
+      }
+    }
+    { % alg >= 0
+    \int_compare:nNnTF { #1 } = { \c_zero }
+      { \tl_set_eq:NN #3 #2 }
+      { \tl_concat:NNN #3 #2 #1 }
+    }
+  
+  % if everything cancels, output 0
+  \tl_if_empty:NTF #3 { \tl_set:Nn #3 { 0 } }
+    {
+    % trim initial + sign
+    \exp_args:NV \tl_if_head_eq_charcode:nNT #3 +
+      { \tl_set:Nx #3 { \tl_tail:N #3 } }
+    }
+  }
+%%%%%%%%%%%
+% messages
+\cs_gset:Npn \msg_error_text:n #1
+  { Unimplemented~in~#1.sty: }
+\cs_gset:Npn \msg_info_text:n #1  
+  { Use~the~order-override~option~to~specify~the~overall~order~of~
+      differentiation~(or~use~diffcoeffx.sty). }
+  
+\msg_new:nnnn { diffcoeff } { unknown_token } 
+  { \msg_error_text:n { diffcoeff }~#2~in~the~order~specification~#1~
+      \msg_line_context:. }
+  { \msg_info_text:n { diffcoeff } }
+  
+\msg_new:nnnn { diffcoeff } { variable_digit_sequence } 
+  { \msg_error_text:n { diffcoeff }~a~digit~follows~a~variable~in~the~order~
+      specification~#1~\msg_line_context:. }
+  { \msg_info_text:n { diffcoeff } }
+
+  
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/diffcoeff/diffcoeffx.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/diffcoeff/diffcoeffx.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/diffcoeff/diffcoeffx.sty	2016-06-27 20:41:31 UTC (rev 41554)
@@ -0,0 +1,972 @@
+% This is file `diffcoeffx.sty'.
+%
+% This program is free software; you can redistribute it and/or modify it 
+% under the terms of the GNU General Public License as published by the 
+% Free Software  Foundation; either version 2 of the License, or (at your
+% option) any later version.
+% 
+% Andrew Parsloe aparsloe at clear.net.nz
+%
+\RequirePackage{expl3}
+\RequirePackage{xparse}
+\ProvidesExplPackage{diffcoeffx} {2015/06/27} {1.0} 
+  {Write differential coefficients easily.}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\cs_generate_variant:Nn \tl_if_eq:nnF { no }
+\cs_generate_variant:Nn \tl_if_eq:nnT { no }
+\cs_generate_variant:Nn \tl_if_in:NnTF { NV }
+\cs_generate_variant:Nn \prop_pop:NnNT { NV }
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% variables
+\tl_new:N \g_diffco_d_ldelim_tl
+\tl_new:N \g_diffco_d_rdelim_tl
+\tl_new:N \g_diffco_p_ldelim_tl
+\tl_new:N \g_diffco_p_rdelim_tl
+
+\tl_new:N \l__diffco_entiand_tl 
+\tl_new:N \l__diffco_phantom_tl
+\tl_new:N \g_diffco_dop_tl
+\tl_new:N \l__diffco_denom_tl
+\tl_new:N \l__diffco_coeff_tl
+
+\clist_new:N \l__diffco_order_clist
+\tl_new:N \l__diffco_order_spec_tl
+\tl_new:N \l__diffco_nudge_tl
+
+\bool_new:N \g__diffco_erent_shape_bool
+\bool_new:N \l__diffco_no_parens_bool
+\bool_new:N \l__diffco_override_bool
+\bool_new:N \l__diffco_ordinary_bool
+\bool_new:N \l__diffco_fp_bool
+\bool_new:N \l__diffco_vars_noted_bool
+
+\tl_new:N \l__diffco_orders_in_tl
+\tl_new:N \l__diffco_order_tl
+
+\tl_new:N \l__diffco_curr_tok_tl
+\tl_new:N \l__diffco_curr_term_tl
+
+\int_new:N \l__diffco_curr_tok_int
+\int_new:N \l__diffco_curr_state_int
+\int_new:N \l__diffco_prev_state_int
+
+\prop_new:N \l__diffco_vars_prop
+\tl_new:N \l__diffco_vars_tl
+\clist_new:N \l__diffco_vars_clist
+
+\tl_new:N \l__diffco_curr_var_tl
+\tl_new:N \l__diffco_curr_qvar_tl
+\tl_new:N \l__diffco_nos_tl
+\tl_new:N \l__diffco_nos_aux_tl
+
+\tl_new:N \l__diffco_alg_tl
+\tl_new:N  \l__diffco_alg_aux_tl
+\tl_new:N \l__diffco_alg_expr_tl
+
+\tl_const:Nn \c__diffco_digits_tl { 1234567890 }
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\keys_define:nn { diffcoeffx }
+  {
+  roman .bool_gset:N  = \g_diffco_roman_bool, 
+  roman .default:n = { false }, 
+  d-delims .code:n = { 
+                      \tl_gset:Nx \g_diffco_d_ldelim_tl { \left \use_i:nn #1 }
+                      \tl_gset:Nx \g_diffco_d_rdelim_tl 
+                          { \right \use_ii:nn #1 }
+                      },
+  d-delims .default:n = { .| },
+  p-delims .code:n = { 
+                      \tl_gset:Nx \g_diffco_p_ldelim_tl { \left \use_i:nn #1 }
+                      \tl_gset:Nx \g_diffco_p_rdelim_tl 
+                          { \right \use_ii:nn #1 }
+                      },
+  p-delims .default:n = { () },
+  d-nudge .code:n = { \tl_gset:Nn \g_diffco_d_nudge_tl { \mskip #1 mu } },
+  d-nudge .default:n = { 0 },
+  p-nudge .code:n = { \tl_gset:Nn \g_diffco_p_nudge_tl { \mskip #1 mu } },
+  p-nudge .default:n = { -6 },
+  sep .code:n = { \tl_gset:Nn \g_diffco_sep_tl { \mskip #1 mu } },
+  sep .default:n = { 2 },
+  d-sep .code:n = { \tl_gset:Nn \g_diffco_d_sep_tl { \mskip #1 mu } },
+  d-sep .default:n = { 1 },
+  p-sep .code:n = { \tl_gset:Nn \g_diffco_p_sep_tl { \mskip #1 mu } },
+  p-sep .default:n = { 1 }
+  }  
+
+\DeclareDocumentCommand \diffset { o }
+  {
+  \IfValueTF { #1 }
+    { 
+    \clist_if_empty:nTF { #1 }
+      { 
+      \keys_set:nn { diffcoeffx } { roman,d-delims,p-delims,
+      d-nudge,p-nudge,sep,d-sep,p-sep }
+      }
+      { 
+      \keys_set:nn { diffcoeffx } { #1 } 
+      }
+    }
+    { 
+    \keys_set:nn { diffcoeffx } { roman,d-delims,p-delims,
+    d-nudge,p-nudge,sep,d-sep,p-sep }
+    }
+  }
+   
+% now set the defaults    
+\diffset  
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Derivatives
+% Ordinary differential coefficient. #1 (star) is the append boolean;
+% #2 is the order; #3 the differentiand; #4 slash / boolean;
+% #5 the variable of differentiation; #6 the point of evaluation. 
+ 
+\NewDocumentCommand \diff{ s o m t/ m g } 
+  {
+  \group_begin:
+  % roman or italic?
+  \bool_if:NF \g__diffco_erent_shape_bool
+    { \__diffco_shape:N d }
+  
+  \IfValueTF { #2 } 
+    { 
+    \tl_set:Nn \l__diffco_order_tl { \g_diffco_d_sep_tl ^{ #2 } }
+    \int_compare:nNnTF { \tl_count:n { #5 } } > { \c_one }
+      { \tl_set:Nn \l__diffco_denom_tl { (#5)^{ #2 } } }
+      { \tl_set:Nn \l__diffco_denom_tl { #5^{ #2 } } }
+    }
+    { 
+    \tl_set:Nn \l__diffco_order_tl { }
+    \tl_if_in:nnTF { #5 } { ^ }
+      { \tl_set:Nn \l__diffco_denom_tl { (#5) } }
+      { \tl_set:Nn \l__diffco_denom_tl { #5 } } 
+    }
+  
+  % differentiand appended (star) or numerator (no star);
+  % slash or fraction?
+  \IfBooleanTF { #1 }
+    { % differentiand follows diff coeff 
+    \__diffco_phantom:n { #3 }
+    \tl_set:Nn \l__diffco_coeff_tl
+      {
+      \IfBooleanTF { #4 }
+        { % slash (therefore no phantom)
+        (\g_diffco_dop_tl \l__diffco_order_tl 
+        /
+        \g_diffco_dop_tl \l__diffco_denom_tl )
+        \l__diffco_entiand_tl
+        }
+        { % frac
+        \frac { \g_diffco_dop_tl \l__diffco_order_tl \l__diffco_phantom_tl }
+            { \g_diffco_dop_tl \l__diffco_denom_tl } \l__diffco_entiand_tl
+        }
+      }
+    }
+    { % differentiand in numerator
+    \tl_set:Nn \l__diffco_coeff_tl
+      {
+      \IfBooleanTF { #4 }
+        { % slash
+        \g_diffco_dop_tl \l__diffco_order_tl #3
+        /
+        \g_diffco_dop_tl \l__diffco_denom_tl 
+        }
+        { % frac
+        \frac { \g_diffco_dop_tl \l__diffco_order_tl #3  }
+          { \g_diffco_dop_tl \l__diffco_denom_tl }
+        }
+      }
+    }
+    
+  % point of eval?
+  \IfNoValueTF { #6 }
+    { % no
+    \l__diffco_coeff_tl 
+    }
+    { % yes
+    \bool_set_true:N \l__diffco_ordinary_bool
+    \__diffco_delims:nnnnN #6;;;;\q_stop \l__diffco_ordinary_bool
+    }
+  \group_end:  
+  }    
+  
+\NewDocumentCommand \Diff { o m m g }
+  {
+  \group_begin:
+  \__diffco_shape:N D 
+  \bool_gset_true:N \g__diffco_erent_shape_bool
+  \diff[#1]{#2}{#3}{#4}
+  \bool_gset_false:N \g__diffco_erent_shape_bool
+  \group_end:
+  }
+  
+\NewDocumentCommand \diffdelta { o m m g } 
+  {
+  \group_begin:
+  \__diffco_shape:N \delta
+  \bool_gset_true:N \g__diffco_erent_shape_bool
+  \diff[#1]{#2}{#3}{#4}
+  \bool_gset_false:N \g__diffco_erent_shape_bool
+  \group_end:
+  }
+  
+\NewDocumentCommand \Diffdelta { o m m g }
+  {
+  \group_begin:
+  \__diffco_shape:N \Delta
+  \bool_gset_true:N \g__diffco_erent_shape_bool
+  \diff[#1]{#2}{#3}{#4}
+  \bool_gset_false:N \g__diffco_erent_shape_bool
+  \group_end:
+  }
+    
+\cs_new_nopar:Npn \__diffco_shape:N #1    
+  {
+  \bool_if:NTF \g_diffco_roman_bool
+    { \tl_gset:Nn \g_diffco_dop_tl { \mathrm{ #1} } }
+    { \tl_gset:Nn \g_diffco_dop_tl { #1 } }
+  } 
+%%%%%
+\cs_new:Npn \__diffco_phantom:n #1
+  {
+  \bool_if:nTF
+      {
+      \tl_if_head_eq_meaning_p:nN { #1 } \hfill ||
+      \tl_if_head_eq_meaning_p:nN { #1 } \hfil
+      }
+      {
+      \l__diffco_phantom_aux:nn #1\q_stop
+      }
+      {
+      \bool_if:nTF
+          {
+          \tl_if_head_eq_meaning_p:nN { #1 } \hspace ||
+          \tl_if_head_eq_meaning_p:nN { #1 } \hphantom
+          }
+        {
+        \l__diffco_phantom_aux:nnn #1\q_stop
+        }
+        {
+        \tl_set:Nn \l__diffco_entiand_tl { #1 } 
+        }
+      }
+  }
+
+\cs_new:Npn \l__diffco_phantom_aux:nn #1#2\q_stop
+  {
+  \tl_set:Nn \l__diffco_phantom_tl { #1 }
+  \tl_set:Nn \l__diffco_entiand_tl { #2 }
+  }
+  
+\cs_new:Npn \l__diffco_phantom_aux:nnn #1#2#3\q_stop
+  {
+  \tl_set:Nn \l__diffco_phantom_tl { #1 { #2  } }
+  \tl_set:Nn \l__diffco_entiand_tl { #3 }
+  }
+%%%%%%%%%%%%%%%%%%%%
+% Partial differential coefficient. #1 (star) = append differentiand 
+% to diff. coeff.(displace from numerator); #2 = comma list of the
+%  orders of diff. in each var.; #3 = order override for the 
+% numerator; #4 = differentiand; #5 = clist of vars of diff. in
+% order; #6 = list of vars held constant
+\NewDocumentCommand \diffp{ s o o t/ m m g } 
+  {
+  \group_begin:
+  
+  % diff. order list 
+  \tl_clear:N \l__diffco_order_clist
+  \IfValueT { #2 }
+    { 
+    \clist_set:Nn \l__diffco_order_clist { #2 }
+    \tl_set:Nx \l__diffco_order_spec_tl 
+        { [\clist_use:Nn \l__diffco_order_clist { , }]}
+    }
+  
+  % order list override  
+  \IfValueT { #3 }
+    { 
+    \bool_set_true:N \l__diffco_override_bool
+    \tl_set:Nn \l__diffco_order_tl { #3 } 
+    }
+    
+  \__diffco_orders:Nn \l__diffco_order_clist { #6 }
+
+  % position of differentiand
+  \IfBooleanTF { #1 }
+    { % appended
+    \__diffco_phantom:n { #5 }
+    \tl_set:Nn \l__diffco_coeff_tl
+        {
+        \frac { \partial
+          \__diffco_omit_order_if_i:N \l__diffco_order_tl
+          \l__diffco_phantom_tl } { \l__diffco_denom_tl }
+        \l__diffco_entiand_tl
+        }
+    }
+    { % in numerator
+    \tl_set:Nn \l__diffco_coeff_tl
+        {
+        \frac { \partial
+           \__diffco_omit_order_if_i:N \l__diffco_order_tl
+           #5 } { \l__diffco_denom_tl }  
+        }
+    }
+  
+  \IfNoValueTF { #7 }
+    { 
+    \l__diffco_coeff_tl 
+    }
+    { % hold some vars const./ pt of eval.
+    \bool_set_false:N \l__diffco_ordinary_bool
+    \__diffco_delims:nnnnN #7;;;;\q_stop \l__diffco_ordinary_bool
+    }
+  
+  \group_end:  
+  } % end of \diffp 
+  
+
+\NewDocumentCommand \jacob { m m }
+  { % need extra braces in denom for clist manipulations
+  \diffp{ (#1) }{ { {{(#2)}} } }
+  }
+ 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
+% #1 subscript; #2 superscript; #3 delims; #4 nudge override
+% #5 detritus; #6 boolean (true = ordinary deriv.; false = partial deriv.)
+\cs_new:Npn \__diffco_delims:nnnnN #1;#2;#3;#4;#5\q_stop#6
+  {
+  \tl_set:Nn \l__diffco_sub_tl { #1 }
+  \tl_set:Nn \l__diffco_super_tl { #2 }
+  \tl_if_empty:nTF { #3 }
+    { % default delims 
+    \bool_if:NTF #6
+      { % ordinary
+      \tl_set_eq:NN \l__diffco_ldelim_tl \g_diffco_d_ldelim_tl
+      \tl_set_eq:NN \l__diffco_rdelim_tl \g_diffco_d_rdelim_tl
+      \tl_if_empty:nTF { #4 }
+        { \tl_set_eq:NN \l__diffco_nudge_tl \g_diffco_d_nudge_tl }
+        { \tl_set:Nn \l__diffco_nudge_tl { \mskip #4 mu } }
+      }
+      { % partial
+      \tl_set_eq:NN \l__diffco_ldelim_tl \g_diffco_p_ldelim_tl
+      \tl_set_eq:NN \l__diffco_rdelim_tl \g_diffco_p_rdelim_tl
+      \tl_if_empty:nTF { #4 }
+        { \tl_set_eq:NN \l__diffco_nudge_tl \g_diffco_p_nudge_tl }
+        { \tl_set:Nn \l__diffco_nudge_tl { \mskip #4 mu } }
+      }
+    }
+    { % delims specified
+    \tl_set:Nn \l__diffco_ldelim_tl { \left \use_i:nn #3 }
+    \tl_set:Nn \l__diffco_rdelim_tl { \right \use_ii:nn #3 }
+    \tl_if_empty:nTF { #4 }
+      { 
+      \tl_set:NV \l_tmpa_tl { \use_ii:nn #3 } 
+      \__diffco_get_nudge:N \l_tmpa_tl
+      }
+      { 
+      \tl_set:Nx \l__diffco_nudge_tl { \mskip #4 mu } 
+      }
+    }
+  \l__diffco_ldelim_tl \l__diffco_coeff_tl \l__diffco_rdelim_tl
+  \tl_if_empty:NF \l__diffco_sub_tl
+    { \c_math_subscript_token { \l__diffco_nudge_tl \l__diffco_sub_tl } }
+  \tl_if_empty:NF \l__diffco_super_tl
+    { \c_math_superscript_token { \l__diffco_nudge_tl \l__diffco_super_tl } }
+  }
+
+\cs_new:Npn \__diffco_get_nudge:N #1
+  { 
+  \exp_args:NV\tl_case:NnF #1
+    {
+    ) { \tl_set:Nn \l__diffco_nudge_tl { \mskip -6mu } }
+    > { \tl_set:Nn \l__diffco_nudge_tl { \mskip -6mu } }
+    \} { \tl_set:Nn \l__diffco_nudge_tl { \mskip -4mu } }
+    \rangle { \tl_set:Nn \l__diffco_nudge_tl { \mskip -6mu } }
+    }
+    { \tl_set:Nn \l__diffco_nudge_tl { \mskip 0mu } }
+  }
+
+% #1 is the clist of diff. orders
+% #2 is the clist of variables
+\cs_new:Npn \__diffco_orders:Nn #1#2
+  {
+  \int_zero:N \l_tmpa_int
+  \tl_clear:N \l_tmpb_tl
+  \clist_clear:N \l_tmpa_clist
+  \clist_clear:N \l_tmpb_clist
+  \clist_clear:N \l__diffco_vars_clist
+
+  \clist_set:Nn \l__diffco_vars_clist { #2 }  
+  \clist_map_inline:Nn \l__diffco_vars_clist
+    {
+    \bool_set_false:N \l__diffco_no_parens_bool
+    
+    % get order of each variable
+    \clist_pop:NNF #1 \l_tmpa_tl 
+      { \tl_set:Nn \l_tmpa_tl { 1 } }
+
+    \tl_if_eq:noT { 1 } \l_tmpa_tl
+      { \bool_set_true:N \l__diffco_no_parens_bool }
+
+    \clist_put_right:NV \l_tmpa_clist \l_tmpa_tl 
+    
+    % create the denominator
+    \tl_clear:N \l_tmpb_tl
+    \bool_if:nTF
+        {
+        \int_compare_p:nNn { \tl_count:n { ##1 } } = { \c_one } 
+        ||
+        \l__diffco_no_parens_bool
+        }
+      { \tl_put_right:Nn \l_tmpb_tl { \partial ##1 } }
+      { \tl_put_right:Nn \l_tmpb_tl { \partial (##1) } }
+
+    \tl_if_eq:noF { 1 } \l_tmpa_tl
+      { 
+      \tl_put_right:Nn \l_tmpb_tl { ^ } 
+      \tl_put_right:Nx \l_tmpb_tl { { \l_tmpa_tl } }
+      }
+
+    \clist_put_right:No \l_tmpb_clist \l_tmpb_tl
+    } % end of inline map
+
+  % numerator order 
+  \bool_if:NF \l__diffco_override_bool
+    {
+    \tl_set:Nx \l__diffco_orders_in_tl { \clist_use:Nn \l_tmpa_clist {+} }
+    \diff_simplify_orders:NN \l__diffco_orders_in_tl \l__diffco_order_tl
+    }
+
+  % denominator
+  \tl_set:Nx \l__diffco_denom_tl { \clist_use:Nn
+        \l_tmpb_clist { \g_diffco_sep_tl } }
+  }
+
+% don't display order 1 superscript
+\cs_new:Npn \__diffco_omit_order_if_i:N #1
+  {
+  \tl_if_eq:noF { 1 } #1
+    { ^{ \g_diffco_p_sep_tl \l__diffco_order_tl } }
+  }
+%%%%%%%%%%%%%%%%%%%%%%
+% #1 is expr. in; #2 is expr. out
+\cs_new:Npn \diff_simplify_orders:NN #1 #2
+  {
+  \tl_clear:N \l__diffco_nos_tl
+ 
+  \__diffco_digest_expr:NNNN #1 \l__diffco_nos_tl 
+      \l__diffco_alg_tl \l__diffco_vars_prop
+
+  \__diffco_eval_nos:N \l__diffco_nos_tl
+  
+  \tl_if_empty:NF \l__diffco_alg_tl
+    { \__diffco_eval_vars:NN \l__diffco_alg_tl \l__diffco_vars_prop }
+  
+  \__diffco_manicure_result:NNN \l__diffco_nos_tl \l__diffco_alg_tl #2
+  }
+
+% #1 is the expression; #2 (tl) receives the numerical part;
+% #3 (tl) receives the algebraic part; #4 (prop) receives the vars
+\cs_new:Npn \__diffco_digest_expr:NNNN #1#2#3#4
+  {  
+  \tl_put_right:Nn #1 { + }
+  \tl_set:Nn \l__diffco_curr_term_tl { + }
+  \int_set:Nn \l__diffco_curr_state_int { \c_zero }
+  \int_set:Nn \l__diffco_prev_state_int { \c_zero }
+  \int_set:Nn \l__diffco_curr_tok_int { \c_zero }
+  \tl_clear:N #3
+  \prop_clear:N #4
+    
+  \tl_map_inline:Nn #1
+    { 
+    \tl_set:Nn \l__diffco_curr_tok_tl { ##1 }
+    \__diffco_get_curr_index:NN ##1 \l__diffco_curr_tok_int
+    \__diffco_compare_states:NNNNN \l__diffco_curr_state_int 
+        \l__diffco_curr_tok_int #2#3#4
+    }
+  \tl_if_empty:NT #2 { \tl_set:Nn #2 { 0 } }
+  }
+
+% #1 contains current token (tl); #2 receives current token index (int)
+\cs_new:Npn \__diffco_get_curr_index:NN #1#2
+  {
+  \tl_if_in:NnTF \c__diffco_digits_tl { #1 }
+    { % digit
+    \int_set:Nn #2 { \c_one }
+    }
+    {
+    \tl_case:NnF #1
+      {
+      + { \int_set_eq:NN #2 \c_zero }
+      - { \int_set_eq:NN #2 \c_zero }
+      ^ { \int_set_eq:NN #2 \c_three }
+      * { \int_set_eq:NN #2 \c_five }
+      \times 
+        { 
+        \int_set_eq:NN #2 \c_five
+        \tl_set:Nn \l__diffco_curr_tok_tl { * }
+        }
+      ( { \int_set_eq:NN #2 \c_six }
+      ) { \int_set_eq:NN #2 \c_seven }
+      }  
+      {
+      \token_if_math_subscript:NTF #1 
+        { \int_set_eq:NN #2 { \c_four } }
+        { 
+        \int_set_eq:NN #2 \c_two }  % var
+      }
+    }
+  }
+ 
+% #1 (int) is curr. state; #2 (int) is curr token index; 
+% #3 (tl) receives the numerical part; 
+% #4 (tl) receives the algebraic part; 
+% #5 (prop) receives the vars
+\cs_new:Npn \__diffco_compare_states:NNNNN #1#2#3#4#5
+  { 
+  \int_case:nn { #1 }
+    { 
+      { \c_zero } % sgn
+        { \__diffco_sgn_transitions:NNNN #1#2#3#4 }
+      { \c_one } % num
+        { \__diffco_num_transitions:NNNN #1#2#3#4 }
+      { \c_two } % alg
+        { \__diffco_alg_transitions:NNNNN #1#2#3#4#5 }
+      { \c_three } % exp
+        { \__diffco_exp_transitions:NN #1#2 }
+      { \c_four } % sub (_)
+        { \__diffco_sub_transitions:NN #1#2 }
+      { \c_five } % mul (*,X)
+        { \__diffco_mul_transitions:NNNN #1#2#3#4 }
+    }
+  }
+  
+% transitions from the signed state
+% #1 = 0, current state; #2 current token index
+% #3 store num. part; #4 store alg. part
+\cs_new:Npn \__diffco_sgn_transitions:NNNN #1#2#3#4
+  {
+  \int_case:nnF { #2 }
+    {
+      { \c_zero } % tok = s
+        {
+        \tl_if_eq:NNTF \l__diffco_curr_term_tl \l__diffco_curr_tok_tl
+          { \tl_set:Nn \l__diffco_curr_term_tl { + } }
+          { \tl_set:Nn \l__diffco_curr_term_tl { - } }
+        \int_set_eq:NN \l__diffco_prev_state_int #1
+        % \int_set:Nn #1 { \c_zero }
+        }
+      { \c_one } % tok = d
+        { \__diffco_term_qvar_append:NN #1 #2 }
+      { \c_two } % tok = v
+        {
+        \tl_put_right:Nn \l__diffco_curr_term_tl { 1 }
+        \__diffco_term_var_append:NN #1 #2
+        }
+      { \c_six } % tok = (
+        {
+        \tl_put_right:Nn \l__diffco_curr_term_tl { 1*( }
+        \tl_put_right:NV #3 \l__diffco_curr_term_tl
+        \tl_put_right:NV #4 \l__diffco_curr_term_tl
+        \tl_set:Nn \l__diffco_curr_term_tl { + }
+        \int_set_eq:NN \l__diffco_prev_state_int #1
+        \int_set:Nn #1 { \c_zero }
+        }
+      { \c_seven } % tok = )
+        {
+        \tl_put_right:Nn #3 { ) }
+        \tl_put_right:Nn #4 { ) }
+        \tl_set:Nn \l__diffco_curr_term_tl { + }
+        \int_set_eq:NN \l__diffco_prev_state_int #1
+        \int_set:Nn #1 { \c_zero }
+        }
+    }
+    {
+    \msg_error:nnxxx { diffcoeffx } { order_spec_construct } 
+      { \l__diffco_order_spec_tl } { \l__diffco_curr_tok_tl } { sign }
+    }
+  }
+  
+% transitions from the numeric state
+% #1 = 1, current state; #2 current token index
+% #3 store num. part; #4 store alg. part
+\cs_new:Npn \__diffco_num_transitions:NNNN #1#2#3#4
+  {
+  \int_case:nnF { #2 }
+    {
+      { \c_zero } % tok = s
+        {
+        \tl_put_right:NV #3 \l__diffco_curr_term_tl 
+        \tl_clear:N \l__diffco_curr_qvar_tl
+        \tl_clear:N \l__diffco_curr_term_tl
+        \__diffco_term_append:NN #1#2
+        }
+      { \c_one } % tok = d
+        { \__diffco_term_qvar_append:NN #1 #2 }
+      { \c_two } % tok = v
+        { 
+        \tl_clear:N \l__diffco_curr_qvar_tl
+        \__diffco_term_var_append:NN #1#2 
+        }
+      { \c_three } % tok = ^
+        { \__diffco_term_qvar_append:NN #1#2 }  
+      { \c_five } % tok = *
+        { 
+        \tl_clear:N \l__diffco_curr_qvar_tl
+        \__diffco_term_append:NN #1#2
+        }
+      { \c_six } % tok = (
+        {
+        \tl_put_right:Nn \l__diffco_curr_term_tl { *( }
+        \tl_put_right:NV #3 \l__diffco_curr_term_tl
+        \tl_put_right:NV #4 \l__diffco_curr_term_tl
+        \tl_set:Nn \l__diffco_curr_term_tl { + }
+        \int_set_eq:NN \l__diffco_prev_state_int #1
+        \int_set:Nn #1 { \c_zero }
+        } 
+      { \c_seven } % tok = )
+        {
+        \tl_put_right:Nn \l__diffco_curr_term_tl { ) }
+        \tl_put_right:NV #3 \l__diffco_curr_term_tl
+        \tl_put_right:Nn #4 { +0) }
+        \tl_set:Nn \l__diffco_curr_term_tl { + }
+        \int_set_eq:NN \l__diffco_prev_state_int #1
+        \int_set:Nn #1 { \c_zero }
+        }
+    }
+    {
+    \msg_error:nnxxx { diffcoeffx } { order_spec_construct } 
+      { \l__diffco_order_spec_tl } { \l__diffco_curr_tok_tl } { number }
+    }
+  }
+
+% transitions from the algebraic state
+% #1 = 2, current state; #2 current token index
+% #3 store num. part; #4 store alg. part; #5 var store
+\cs_new:Npn \__diffco_alg_transitions:NNNNN #1#2#3#4#5
+  { 
+  \int_case:nnF { #2 }
+    {
+      { \c_zero } % tok = s
+        { 
+        \bool_if:NF \l__diffco_vars_noted_bool
+          { \__diffco_store_var:NN #5 \l__diffco_curr_var_tl }
+        \tl_clear:N \l__diffco_curr_var_tl
+        \tl_put_right:NV #4 \l__diffco_curr_term_tl
+        \tl_clear:N \l__diffco_curr_term_tl
+        \__diffco_term_append:NN #1 #2
+        }
+      { \c_one } % tok = d
+        {
+        \int_compare:nNnTF { \l__diffco_prev_state_int } = { \c_three }
+          { \__diffco_term_var_append:NN #1 \c_two }
+          { 
+          \msg_error:nnxxx { diffcoeffx } { order_spec_construct } 
+            { \l__diffco_order_spec_tl } { \l__diffco_curr_tok_tl } 
+            { variable }
+          }
+        }
+      { \c_two } % tok = v
+        { \__diffco_term_var_append:NN #1 #2 }
+
+      { \c_three } % tok = ^
+        { \__diffco_term_var_append:NN #1#2 }  
+      { \c_four } % tok = _
+        { \__diffco_term_var_append:NN #1#2 }
+      { \c_seven } % tok = )
+        {
+        \bool_if:NF \l__diffco_vars_noted_bool
+          { \__diffco_store_var:NN #5 \l__diffco_curr_var_tl }
+        \tl_clear:N \l__diffco_curr_var_tl 
+        \tl_put_right:Nn \l__diffco_curr_term_tl { ) }
+        \tl_put_right:Nn #3 { +0) }
+        \tl_put_right:NV #4 \l__diffco_curr_term_tl
+        \tl_set:Nn \l__diffco_curr_term_tl { + }
+        \int_set_eq:NN \l__diffco_prev_state_int #1
+        \int_set:Nn #1 { \c_zero }
+        }              
+    }
+    {
+    \msg_error:nnxxx { diffcoeffx } { order_spec_construct } 
+      { \l__diffco_order_spec_tl } { \l__diffco_curr_tok_tl } { variable }
+    }
+  }
+
+% transitions from the exponent state
+% #1 = 3, current state; #2 current token index
+\cs_new:Npn \__diffco_exp_transitions:NN #1#2
+  {
+  \int_case:nn { \l__diffco_prev_state_int }
+    { 
+      { \c_one } % prev = num
+        { 
+        \int_case:nnF { #2 }
+          {
+            { \c_one } % tok = d
+              {
+              \tl_clear:N \l__diffco_curr_qvar_tl
+              \tl_put_right:Nn \l__diffco_curr_tok_tl { * }
+              \__diffco_term_append:NN #1 \c_five
+              \bool_set_true:N \l__diffco_fp_bool
+              }
+            { \c_two } % tok = v
+              {
+              \__diffco_term_qvar_append:NN #1 \c_two
+              \tl_set_eq:NN \l__diffco_curr_var_tl \l__diffco_curr_qvar_tl
+              \tl_clear:N \l__diffco_curr_qvar_tl
+              }
+          }
+          {
+          \msg_error:nnxxx { diffcoeffx } { order_spec_construct } 
+            { \l__diffco_order_spec_tl } { \l__diffco_curr_tok_tl } { ^ }
+          }
+        }
+      { \c_two } % prev = alg
+        {
+        \int_compare:nNnTF { #2 } < { \c_three }
+          { \__diffco_term_var_append:NN #1 \c_two }
+          {
+          \msg_error:nnxxx { diffcoeffx } { order_spec_construct } 
+            { \l__diffco_order_spec_tl } { \l__diffco_curr_tok_tl } { ^ }
+          }
+        }
+    }
+  }
+
+% transitions from the subscript state
+% #1 = 4, current state; #2 current token index
+\cs_new:Npn \__diffco_sub_transitions:NN #1#2  
+  {
+  \bool_if:nTF 
+      {(
+      \int_compare_p:nNn { \l__diffco_prev_state_int } = { \c_two } &&
+      \int_compare_p:nNn { #2 } < { \c_three }
+      )}
+    { 
+    \__diffco_term_var_append:NN #1 \c_two 
+    }
+    {
+    \msg_error:nnxxx { diffcoeffx } { order_spec_construct } 
+      { \l__diffco_order_spec_tl } { \l__diffco_curr_tok_tl } { _ }
+    }
+  }
+  
+% transitions from the multiplicative state
+% #1 = 5, current state; #2 current token index
+% #3 store num. part; #4 store alg. part
+\cs_new:Npn \__diffco_mul_transitions:NNNN #1#2#3#4
+  { 
+  \int_case:nnF { #2 }
+    {
+      { \c_zero } % tok = s
+        {
+        \int_compare:nNnTF {\l__diffco_prev_state_int } = { \c_three }
+          {
+          \tl_put_right:Nn \l__diffco_curr_term_tl { 1 }
+          \tl_put_right:NV #3 \l__diffco_curr_term_tl
+          \tl_clear:N \l__diffco_curr_term_tl
+          \__diffco_term_append:NN #1 #2 
+          }
+          {
+          \msg_error:nnxxx { diffcoeffx } { order_spec_construct } 
+            { \l__diffco_order_spec_tl } { \l__diffco_curr_tok_tl } 
+            { multiplicative~token }
+          }
+        }
+      { \c_one } % tok = d
+        { \__diffco_term_qvar_append:NN #1 #2 }
+      { \c_two } % tok = v
+        { 
+        \tl_put_right:Nn \l__diffco_curr_term_tl {1 }
+        \__diffco_term_var_append:NN #1#2
+        }
+      { \c_five } % tok = *
+        { \prg_do_nothing: }  
+      { \c_six } % tok = (
+        {
+        \tl_put_right:Nn \l__diffco_curr_term_tl { ( }
+        \tl_put_right:NV #3 \l__diffco_curr_term_tl
+        \tl_put_right:NV #4 \l__diffco_curr_term_tl
+        \tl_set:Nn \l__diffco_curr_term_tl { + }
+        \int_set_eq:NN \l__diffco_prev_state_int #1
+        \int_set:Nn #1 { \c_zero }
+        }
+    }
+    {
+    \msg_error:nnxxx { diffcoeffx } { order_spec_construct } 
+      { \l__diffco_order_spec_tl } { \l__diffco_curr_tok_tl } 
+      { multiplicative~token }
+    }
+  }
+
+%%%%%%%%%%%%%%%%%%%
+% term/var/qvar appending routines  
+% #1 current state; #2 current token index
+\cs_new:Npn \__diffco_term_var_append:NN #1#2
+  {
+  \tl_put_right:NV \l__diffco_curr_term_tl \l__diffco_curr_tok_tl
+  \tl_put_right:NV \l__diffco_curr_var_tl \l__diffco_curr_tok_tl
+  \int_set_eq:NN \l__diffco_prev_state_int #1
+  \int_set_eq:NN #1 #2
+  }
+  
+% #1 current state; #2 current token index
+\cs_new:Npn \__diffco_term_qvar_append:NN #1#2
+  {
+  \tl_put_right:NV \l__diffco_curr_term_tl \l__diffco_curr_tok_tl
+  \tl_put_right:NV \l__diffco_curr_qvar_tl \l__diffco_curr_tok_tl
+  \int_set_eq:NN \l__diffco_prev_state_int #1
+  \int_set_eq:NN #1 #2
+  }  
+
+% #1 current state; #2 current token index
+\cs_new:Npn \__diffco_term_append:NN #1#2
+  {
+  \tl_put_right:NV \l__diffco_curr_term_tl \l__diffco_curr_tok_tl
+  \int_set_eq:NN \l__diffco_prev_state_int #1
+  \int_set_eq:NN #1 #2
+  }  
+  
+% #1 is prop list; #2 is tl containing var
+\cs_new:Npn  \__diffco_store_var:NN #1 #2
+  {
+  \int_set:Nn \l_tmpa_int { \exp_args:NV \tl_count_tokens:n #2 }
+  \prop_get:NVNTF #1 \l_tmpa_int \l_tmpa_tl
+    {
+    \tl_put_right:Nn \l_tmpa_tl { , }
+    \tl_put_right:NV \l_tmpa_tl #2
+    \prop_put:NVV #1 \l_tmpa_int \l_tmpa_tl
+    }
+    {
+    \prop_put:NVV #1 \l_tmpa_int #2
+    }
+  }
+  
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% evals numerical expr. in #1, which receives the
+% evaluated expr.
+\cs_new:Npn \__diffco_eval_nos:N #1 
+  {
+  \bool_if:NTF \l__diffco_fp_bool
+    { % exponent; use l3fp
+    \fp_set:Nn \l_tmpa_fp { #1 }
+    \int_set:Nn \l_tmpa_int { \fp_use:N \l_tmpa_fp }
+    \bool_set_false:N \l__diffco_fp_bool
+    }
+    { % normal mode; use l3int
+    \int_set:Nn \l_tmpa_int { #1 }
+    }
+  \tl_set:Nx  #1 { \int_use:N \l_tmpa_int } 
+
+  \int_compare:nNnT { \l_tmpa_int } > { \c_zero }
+    { \tl_put_left:Nn #1 { + } }
+  }
+
+% #1 (tl) has algebraic part & receives eval. expression
+% #2 (prop) contains the variables
+% The idea is to remove each var but leave coeffs, split into
+% num & alg parts, eval. the num part for the net coeff of var
+\cs_new:Npn \__diffco_eval_vars:NN #1#2
+  { 
+  \bool_set_true:N \l__diffco_vars_noted_bool
+  \prop_set_eq:NN \l_tmpa_prop #2
+  \int_set_eq:NN \l_tmpa_int \c_one
+  \bool_until_do:nn { \prop_if_empty_p:N #2 }
+    {
+    \prop_pop:NVNT #2 \l_tmpa_int \l_tmpa_tl
+      {
+      \tl_put_left:Nn \l_tmpa_tl { , }
+      \tl_put_left:NV \l__diffco_vars_tl  \l_tmpa_tl
+      }
+    \int_incr:N \l_tmpa_int
+    }
+    
+  \clist_set:NV \l__diffco_vars_clist \l__diffco_vars_tl
+  \clist_remove_duplicates:N \l__diffco_vars_clist
+  \bool_if:NF \l__diffco_override_bool
+    {
+    \clist_map_inline:Nn \l__diffco_vars_clist
+      {
+      \tl_replace_all:Nnn #1 { ##1 } { }
+      \__diffco_digest_expr:NNNN #1 \l__diffco_nos_aux_tl 
+          \l__diffco_alg_aux_tl \l_tmpa_prop
+      \__diffco_eval_nos:N \l__diffco_nos_aux_tl
+       
+      \__diffco_cumulate_expr:NnN \l__diffco_nos_aux_tl { ##1 }
+          \l__diffco_alg_expr_tl
+       
+      \tl_set_eq:NN #1 \l__diffco_alg_aux_tl
+      \tl_clear:N \l__diffco_nos_aux_tl
+      \tl_clear:N \l__diffco_alg_aux_tl
+      }
+    }
+  \tl_set_eq:NN #1 \l__diffco_alg_expr_tl
+  }
+
+% #1 is num coeff; #2 is var; #3 is cumulating expr. (All tl.)
+\cs_new:Npn \__diffco_cumulate_expr:NnN #1#2#3
+  { 
+  \int_case:nnF { #1 }
+    {
+      { 0 } { \prg_do_nothing: }
+      { +1 } { \tl_put_right:Nn #3 { + #2 } }
+      { -1 } { \tl_put_right:Nn #3 { - #2 } }
+    }
+    {
+    \tl_put_right:NV #3 { #1 } 
+    \exp_args:NNx \tl_if_in:NnT \c__diffco_digits_tl { \tl_head:n { #2 } }
+      { \tl_put_right:Nn #3 { \times} }
+    \tl_put_right:Nn #3 { #2 }
+    }
+  }
+
+% alg. part precedes num. part unless alg. starts 
+% with - and nums > 0. #1 nums, #2 alg, #3 output 
+\cs_new:Npn \__diffco_manicure_result:NNN #1#2#3
+  { % alg < 0 ?
+  \exp_args:NV \tl_if_head_eq_charcode:nNTF #2 -
+    {
+    \int_compare:nNnTF { #1 } > { \c_zero }
+      {  % nums > 0
+      \tl_concat:NNN #3 #1 #2
+      }
+      {  % nums =< 0
+      \seq_set_split:NnV \l_tmpa_seq { + } #2    
+      \seq_pop:NN \l_tmpa_seq \l_tmpa_tl
+      \tl_set:Nx \l_tmpb_tl { \seq_use:Nn \l_tmpa_seq { + } }
+      \int_compare:nNnF { #1 } = { \c_zero }
+        { \tl_concat:NNN \l_tmpa_tl \l_tmpa_tl #1 }
+      \tl_concat:NNN #3 \l_tmpb_tl \l_tmpa_tl
+      }
+    }
+    { % alg >= 0
+    \int_compare:nNnTF { #1 } = { \c_zero }
+      { \tl_set_eq:NN #3 #2 }
+      { \tl_concat:NNN #3 #2 #1 }
+    }
+
+  % if everything cancels, output 0
+  \tl_if_empty:NTF #3 { \tl_set:Nn #3 { 0 } }
+    {
+    % trim initial + sign
+    \exp_args:NV \tl_if_head_eq_charcode:nNT #3 +
+      { \tl_set:Nx #3 { \tl_tail:N #3 } }
+    }
+  }
+
+%%%%%%%%%%%%%%%%%%%%
+% messages
+\cs_gset:Npn \msg_error_text:n #1
+  { #1.sty.~Is~this~construction~intended }
+\cs_gset:Npn \msg_info_text:n #1  
+  { If~intended~then~use~the~order-override~option~to~specify~the~overall~
+      order~of~differentiation. }
+  
+\msg_new:nnnn { diffcoeffx } { order_spec_construct } 
+  { \msg_error_text:n { diffcoeffx }:~#3~followed~by~#2~in~the~order~
+      specification~#1~\msg_line_context:? } 
+  { \msg_info_text:n { diffcoeffx } }
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/latex/diffcoeff/diffcoeffx.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check	2016-06-27 20:40:03 UTC (rev 41553)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2016-06-27 20:41:31 UTC (rev 41554)
@@ -197,7 +197,7 @@
     dejavu
     delim delimseasy delimtxt denisbdoc dhua
     diadia diagbox diagmac2 dialogl diagnose dice dichokey
-    dickimaw dictsym digiconfigs din1505
+    dickimaw dictsym diffcoeff digiconfigs din1505
     dinat dinbrief dingbat directory dirtree dirtytalk disser dithesis
     dk-bib dlfltxb
     dnaseq dnp doc-pictex docbytex doclicense

Modified: trunk/Master/tlpkg/tlpsrc/collection-mathextra.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-mathextra.tlpsrc	2016-06-27 20:40:03 UTC (rev 41553)
+++ trunk/Master/tlpkg/tlpsrc/collection-mathextra.tlpsrc	2016-06-27 20:41:31 UTC (rev 41554)
@@ -21,6 +21,7 @@
 depend conteq
 depend delim
 depend delimseasy
+depend diffcoeff
 depend drawmatrix
 depend ebproof
 depend econometrics

Added: trunk/Master/tlpkg/tlpsrc/diffcoeff.tlpsrc
===================================================================


More information about the tex-live-commits mailing list