LATEX-L Archives

Mailing list for the LaTeX3 project


Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
aparsloe <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Mon, 24 Nov 2014 14:10:17 +1300
text/plain (81 lines)
About a century ago in their "Principia Mathematica" Russell and 
Whitehead established, after enormous labour (p.379 apparently), that 
1+1=2. It delights me that now, late in 2014, we can put this to the 
test and, indeed, confirm it:

\fp_eval:n {  .^. + .**.  }

The march of progress!

Please view the preceding little joke as a pre-emptive strike. I have 
just "finished" a package called calculyx.sty. Among much else it makes 
use of this unusual deployment of the decimal point (specifically 
\fp_eval:n { . } ), and it would inconvenience me considerably were this 
to be prevented. Calculyx runs to about 3900 lines of code (but with 
many formatting lines). Considering that I had never managed more than 
10 to 20 lines of TeX/LaTeX code before, it is a tribute to the enabling 
powers of expl3. I even began to feel that coding with expl3 was 
intuitive (god help me).

The "roadmap" in interface3.pdf remarks of l3fp that "this module is 
mostly meant as an underlying tool for higher-level commands. For 
example, one could provide a function to typeset nicely the result of 
floating point computations." When I saw the calculation preceding the 
remark, I realised that it was "made to measure" for the instant preview 
facility in LyX. That is what I have done. One enters an expression in 
the LyX math editor, moves the cursor outside the editor, and after a 
(brief) pause, the calculation is effected and the answer snaps into view.

As well as many modules from l3kernel, the package uses xparse from 
l3packages and l3regex from l3experimental. Because a main routine uses 
the command \clist_reverse:N, which was introduced to l3kernel on 18 
July 2014, the version of l3kernel must be later than this. There is a 
link at to a zipped archive 
currently in a Dropbox folder. I shall wait a while for any feedback 
before considering a more permanent location.

I have tried to ensure as much as possible that calculyx reads 
expressions as mathematicians write them. For instance it will "digest" 
\sin 3x - 3\sin x + 4\sin^{3} x (for a specified value of x, say \pi/6) 
without parentheses around the arguments and with the superscript in the 
"wrong" but familiar place. The l3fp machinery is hidden from view. 
Although written specifically for LyX, the package can be used 
independently but one needs to bear in mind that it expects LyXian 
LaTeX. I think this amounts to the following conditions:  superscripts 
and subscripts are *always* wrapped in braces and, for the limits on 
summation signs, product signs and integrals, the lower limit *always* 
precedes the upper (e.g. \sum_{n=1}^{7}  ). The link 
gives a screenshot (.png format) of a one page LaTeX document 
illustrating some examples of calculations, and the resulting pdf.

Calculyx will "digest" a number of functions not covered in l3fp. I have 
implemented the three principal hyperbolic functions and their inverses 
(with the -1 notation: \tanh^{-1} ), factorials (the ! notation -- and 
why on earth do mathematicians write it *after* the number it 
qualifies?), binomial coefficients, gcd, sums and products, including 
"infinite" sums and products, limits, derivatives (1st & 2nd order) and 
definite integrals in a single variable.  I found the pull from one 
function to the next irresistible. Having implemented sums (and 
products), it's hard not to consider factorials and binomial 
coefficients, and doubly hard to resist the siren song of infinite sums. 
Infinite sums lead naturally to limits generally, and it is then only a 
small step to derivatives, and you can hardly have derivatives without 
also having integrals.

In fact I began to feel that there is a tension in l3fp, as if it is 
caught between two forces: one, a restrictive force limiting the set of 
functions to those appropriate to l3kernel, the other an expansionary 
pull of the kind I experienced. What does the kernel need? Let me 
display my ignorance: the four arithmetic functions, integral powers, 
and square roots. That covers things like scaling of fonts and paper 
sizes, calculation of margins, and most shaped paragraphs. But the l3fp 
roadmap mentions things like factorials, the gamma function(!), arrays, 
complex numbers. Yes please, but in the kernel? I am deeply thankful for 
what Bruno has already provided but can't help thinking that the module 
should "go the whole hog" and implement everything (so to speak). To my 
mind that would fit much more naturally as a full-blown LaTeX package 
(in l3packages?).