Should l3fp use juxtaposition *at all* to indicate multiplication? I am
an enthusiast for l3fp. I am using it constantly (in LyX using LyX's
instant preview to evaluate formulas), but that has simply heightened my
unease about using juxtaposition to indicate multiplication,
particularly as part of a kernel package.
Most people using numbers have their mental reflexes shaped either by
mathematical usage or calculator or spreadsheet usage. The last two, to
my knowledge, don't allow juxtaposition. Multiplication must be
explicitly indicated with an asterisk.
Mathematical usage is variable and often irregular but there is a
certain core understanding. In a polynomial like 2x^35x^29 it is
universally understood that the cubing and squaring applies only to the
x, not the coefficients. In l3fp, however, because juxtaposition has the
highest precedence, the coefficients are "glued" to the x so that it is
2x that is cubed and 5x that is squared (e.g. on putting (2+3) for x).
Usually the answers from "normal" and l3fp evaluation will be
sufficiently different to alert one to the fact that something has gone
wrong, but occasionally they will be "in the same ball park" and may
lead to overlooking an error.
For instance scaling paper sizes or text blocks may lead one to seek the
length of the diagonal of a rectangle, say the initial one with sides
21cm and 29.7cm and a larger one with sides 1.2 times greater. What is
the larger diagonal? By similarity, it is 1.2 times the length of the
smaller diagonal. It is very easy to write 1.2(21^2+29.7^2)^.5 (with
1.2\times\sqrt{21^2+29.7^2} in mind), evaluate it with fp and get
39.85cm. This is wrong but not too obviously different from the correct
43.65cm.
Juxtaposition also produces conflicts with established practice
(calculators, spreadsheets) for function calls. Yes, sin2pi evaluates to
0 as does sin(2pi), but sin(2pi)(2pi) = 0.978... does not, so that a
function's argument is not delimited by parentheses, even when
parentheses are used. That also breaks a longestablished practice and
seems like a source of error for the unwary.
I find myself now shunning juxtaposition and making a point of
explicitly indicating multiplication with an asterisk, even in cases
like 2*pi  in other words making it a habit of mind precisely to avoid
these "traps for the unwary". I imagine the juxtapositional horse has
well and truly bolted, but I find myself wondering if it still might be
possible to graft a strict "calculator front end" onto l3fp to align its
operations with more familiar habits of mind?
Andrew Parsloe
